While working with keycloak Java Distribution 8.0.0 API and quarkus I have an issue in creating Keycloak objects.
dependencies list
<properties>
<compiler-plugin.version>3.8.1</compiler-plugin.version>
<maven.compiler.parameters>true</maven.compiler.parameters>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus-plugin.version>1.0.0.CR2</quarkus-plugin.version>
<quarkus.platform.artifact-id>quarkus-universe-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.version>1.0.0.CR2</quarkus.platform.version>
<surefire-plugin.version>2.22.1</surefire-plugin.version>
</properties>
...
<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>8.0.0</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
</dependencies>
main method
public static void main(String[] args) {
String serverUrl = "http://localhost:8181/auth";
String realmId = "master";
String clientId = "admin-cli";
KeycloakClient client = new KeycloakClient(serverUrl, realmId, clientId);
Keycloak kc = client.getKeycloak("adminuser", "adminpassword");
RealmResource realmResource = kc.realm("keycloak-client");
UsersResource userRessource = realmResource.users();
if (userRessource != null) {
System.out.println("Count: " + userRessource.count());
} else {
System.out.println("null");
}
}
keycloak client class
public Keycloak getKeycloak(final String username, final String password) {
// Type mismatch: cannot convert from Client to ResteasyClient
ResteasyClient resteasyClient = new ResteasyClientBuilder().connectionPoolSize(10)
.register(new CustomJacksonProvider()).build();
return KeycloakBuilder.builder().serverUrl(this.serverUrl).realm(this.realmId).username(username)
.password(password).clientId(this.clientId).resteasyClient(resteasyClient).build();
}
I came to know that the issue was caused due to keycloak-admin-client which still use ResteasyClient as a Class here so i changed my dependency list to the following.
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-client</artifactId>
<version>8.0.0</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<version>3.6.3.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<version>3.6.3.Final</version>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>3.6.3.Final</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
Now the Main method working fine but I got another error.
Caused by: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.resteasy.server.common.deployment.ResteasyServerCommonProcessor#build threw an exception: java.lang.IncompatibleClassChangeError: Implementing class
I want to know that is that possible to work quarkus and keycloak-admin alongside with current version. else there any workaround possible.
Thanks
Related
I'm trying to use DBCPConnectionPool service in my custom processor. So, how to use in-built controller services (which are already available on NiFi) in our custom processors.
Here are my properties in *-nar/->pom.xml
<dependencies>
<dependency>
<groupId>org.sample.com</groupId>
<artifactId>nifi-customprocessor-processors</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-standard-services-api-nar</artifactId>
<version>1.14.0</version>
<type>nar</type>
</dependency>
</dependencies>
Here are my dependencies in *processors/->pom.xml
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-utils</artifactId>
<version>1.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-mock</artifactId>
<version>1.14.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-dbcp-service</artifactId>
<version>1.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-dbcp-service-api</artifactId>
<version>1.14.0</version>
</dependency>
And here is my propertydescriptor for DBCPConnetionPool service :-
public static final PropertyDescriptor DBCPConnectionPool_SERVICE = new PropertyDescriptor.Builder()
.name("DBCPConnectionPoolLookup Service")
.description("The Controller Service to use in order to establish a connection")
.required(true)
.dynamic(true)
.identifiesControllerService(DBCPService.class)
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
.build();
and in my OnTrigger method I didn't used it as :-
DBCPService DBCPService = context.getProperty(DBCPConnectionPool_SERVICE)
.asControllerService(DBCPService.class);
Connection con = DBCPService.getConnection();
and was trying to use this con object as in regular passion createStatement->executeQuery.
When I tried to package it using mvn clean install it started throwing error as : A required class was missing while executing org.apache.nifi:nifi-nar-maven-plugi
n:1.3.1:nar: org/apache/nifi/record/sink/RecordSinkService
then I added the following dependencies in processors/->pom.xml
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-record-sink-service</artifactId>
<version>1.14.0</version>
</dependency>
<dependency>
<groupId>org.apache.nifi</groupId>
<artifactId>nifi-record-sink-api</artifactId>
<version>1.14.0</version>
</dependency>
This time it was new error as :- Failed to create Extension Definition for CONTROLLER_SERVICE org.apache.nifi.record.sink.lookup.RecordSinkServiceLookup: Null
PointerException
I also checked by commenting out code which I have written, to check the way I'm using that property was wrong but, even that didn't worked.:-
DBCPService DBCPService = context.getProperty(DBCPConnectionPool_SERVICE)
.asControllerService(DBCPService.class);
Connection con = DBCPService.getConnection();
Can someone help me out in order to use DBCPConnectionPoolService controller service in my custom processor?
I had the same issues the other day and I solved it by using AbstractControllerService instead of DBCPConnectionPool therefore not needing org.apache.nifi.dbcp.DBCPService anymore. Therefore my code would look like this:
MyService DBCPService = context.getProperty(DBCPConnectionPool_SERVICE)
.asControllerService(MyService.class);
Connection con = DBCPService.getConnection();
MyService is the custom interface that extends ControllerService.(you have to use it when you also define the PropertyDescriptor DBCPConnectionPool_SERVICE)
And StandardMyService the class that extends AbstractControllerService and implements MyService and getConnection() from it.
This is my pom.xml
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.1.6.RELEASE
com.dummy
lattt
0.0.1-SNAPSHOT
war
lattt
lattt
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.2.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180813</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>dev.morphia.morphia</groupId>
<artifactId>core</artifactId>
<version>1.5.3</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-oauth2</artifactId>
<version>v2-rev150-1.25.0</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.2.11</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
</dependency>
<dependency>
<groupId>org.javers</groupId>
<artifactId>javers-core</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.23.1-GA</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-secretsmanager</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- Mockito -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<!-- PowerMock -->
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>2.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>2.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.2</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.11.618</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.0</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<phase>prepare-package</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.6.2</version>
</extension>
</extensions>
<finalName>${project.artifactId}</finalName>
</build>
<profiles>
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://sonar.com
</sonar.host.url>
<sonar.login>
dummy
</sonar.login>
</properties>
</profile>
</profiles>
I have 2 junit test and these are failing repeatedly
1.Installed and Using jdk 8
2.But aws-sdk-bom runs with 1.11.618 and downloads&executes test with 1.11.618
3.And throws the error
10:16:49.904 [main] DEBUG com.amazonaws.AmazonWebServiceClient - Internal logging successfully configured to commons logger: true
10:16:49.913 [main] DEBUG com.amazonaws.metrics.AwsSdkMetrics - Admin mbean registered under com.amazonaws.management:type=AwsSdkMetrics
10:16:50.092 [main] DEBUG com.amazonaws.monitoring.CsmConfigurationProviderChain - Unable to load configuration from com.amazonaws.monitoring.EnvironmentVariableCsmConfigurationProvider#2622fd05: Unable to load Client Side Monitoring configurations from environment variables!
10:16:50.093 [java-sdk-http-connection-reaper] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Closing connections idle longer than 60000 MILLISECONDS
10:16:50.093 [main] DEBUG com.amazonaws.monitoring.CsmConfigurationProviderChain - Unable to load configuration from com.amazonaws.monitoring.SystemPropertyCsmConfigurationProvider#7e5ecc5f: Unable to load Client Side Monitoring configurations from system properties variables!
10:16:50.096 [main] DEBUG com.amazonaws.monitoring.CsmConfigurationProviderChain - Unable to load configuration from com.amazonaws.monitoring.ProfileCsmConfigurationProvider#3b38e484: Unable to load config file
setup
[[1;31mERROR[m] [1;31mTests [0;1mrun: [0;1m8[m, Failures: 0, [1;31mErrors: [0;1;31m8[m, Skipped: 0, Time elapsed: 21.379 s[1;31m <<< FAILURE![m - in com.logi.bootstrap.controller.[1mStoreControllerTest[m
[[1;31mERROR[m] updateStoresByAdmin(com.logi.bootstrap.controller.StoreControllerTest) Time elapsed: 0.77 s <<< ERROR!
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.security.authentication.ProviderNotFoundException: No AuthenticationProvider found for org.springframework.security.authentication.TestingAuthenticationToken
at com.logi.bootstrap.controller.StoreControllerTest.updateStoresByAdmin(StoreControllerTest.java:155)
Caused by: org.springframework.security.authentication.ProviderNotFoundException: No AuthenticationProvider found for org.springframework.security.authentication.TestingAuthenticationToken
at com.logi.bootstrap.controller.StoreControllerTest.updateStoresByAdmin(StoreControllerTest.java:155)
Test file
#RunWith(PowerMockRunner.class)
#PowerMockRunnerDelegate(SpringRunner.class)
#PowerMockIgnore({ "javax.management.*", "org.apache.http.conn.ssl.*", "com.amazonaws.*", "javax.net.ssl.*",
"com.mongodb.*", "dev.morphia.*","javax.security.*" })
#SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.MOCK, classes = LatApplication.class)
#WebAppConfiguration
#Import({TestConfig.class})
#PrepareForTest({ AdminChecker.class, StoreTable.class })
public class StoreControllerTest {
#Autowired
private WebApplicationContext webApplicationContext;
private MockMvc mvc;
#MockBean
StoreTable storeTbl;
#MockBean
RegionalAdminTable regionAdminTbl;
#MockBean
AccountServiceHandler accSrvHandler;
#Before
public void setup() {
System.out.println("setup");
mvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
}
#Test
#WithMockUser(roles = { "administrator" },value="demo#example.com")
public void getStoresByAdmin() throws Exception {
// given
// 308 store in the system
PowerMockito.mockStatic(AdminChecker.class);
JSONArray arr = new JSONArray();
JSONObject result = new JSONObject();
result.put("resultList", arr);
PowerMockito.when(AdminChecker.checkIsAdmin(Mockito.any())).thenReturn(true);
// when
// admin get store list
// then
mvc.perform(MockMvcRequestBuilders.get("/stores").contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()).andExpect(jsonPath("$.resultList", hasSize(0)));
}
#Test
#WithMockUser(roles = { "agent" })
public void getStoresByAgent() throws Exception {
// given
// 308 store in the system
PowerMockito.mockStatic(AdminChecker.class);
JSONArray arr = new JSONArray();
JSONObject result = new JSONObject();
result.put("resultList", arr);
PowerMockito.when(AdminChecker.checkIsAdmin(Mockito.any())).thenReturn(false);
PowerMockito.when(accSrvHandler.getNameByEmail(Mockito.anyString())).thenReturn("test");
// when
// admin get store list
// then
mvc.perform(MockMvcRequestBuilders.get("/stores").contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
}
#Test
#WithMockUser(roles = { "administrator" }, username = "myUser")
//#WithUserDetails("sys#sys.com")
public void createStoresByAdmin() throws Exception {
// given
// 308 store in the system
ObjectMapper mapper = new ObjectMapper();
Mockito.doNothing().when(storeTbl).save(Mockito.any());
Authentication auth = Mockito.mock(Authentication.class);
Mockito.when(auth.getName()).thenReturn("demo#example.com");
// when
Store newStore = new Store();
// admin get store list
// then
// System.out.println(storeTbl);
mvc.perform(MockMvcRequestBuilders.post("/stores").contentType(MediaType.APPLICATION_JSON)
.content(mapper.writeValueAsString(newStore))).andExpect(status().isOk());
}
#Test
#WithMockUser(roles = { "administrator" }, username = "myUser")
// #WithUserDetails("sys#sys.com")
public void createStoresFailByAdmin() throws Exception {
// given
// 308 store in the system
ObjectMapper mapper = new ObjectMapper();
Mockito.when(storeTbl.checkExist(Mockito.any(Store.class))).thenReturn(true);
Mockito.doNothing().when(storeTbl).save(Mockito.any());
Authentication auth = Mockito.mock(Authentication.class);
Mockito.when(auth.getName()).thenReturn("demo#example.com");
// when
Store newStore = new Store();
// admin get store list
// then
// System.out.println(storeTbl);
mvc.perform(MockMvcRequestBuilders.post("/stores")
.contentType(MediaType.APPLICATION_JSON).content(mapper.writeValueAsString(newStore)))
.andExpect(status().isConflict());
}
#Test
//#WithMockUser(roles = { "administrator" })
#WithUserDetails("sys#sys.com")
public void updateStoresByAdmin() throws Exception {
// given
// a store in the system
ObjectMapper mapper = new ObjectMapper();
Mockito.doNothing().when(storeTbl).save(Mockito.any());
Mockito.when(storeTbl.getStoreById(Mockito.anyString())).thenReturn(new Store());
// when
Store newStore = new Store();
// admin get store list
// then
// System.out.println(storeTbl);
mvc.perform(MockMvcRequestBuilders.put("/stores/test").contentType(MediaType.APPLICATION_JSON)
.content(mapper.writeValueAsString(newStore))).andExpect(status().isOk());
}
#Test
#WithMockUser(roles = { "administrator" }, username = "myUser")
public void updateStoresFailByAdmin() throws Exception {
// given
// a store in the system
ObjectMapper mapper = new ObjectMapper();
Mockito.doNothing().when(storeTbl).save(Mockito.any());
Mockito.when(storeTbl.getStoreById(Mockito.anyString())).thenReturn(null);
Authentication auth = Mockito.mock(Authentication.class);
Mockito.when(auth.getName()).thenReturn("demo#example.com");
// when
Store newStore = new Store();
// admin get store list
// then
// System.out.println(storeTbl);
mvc.perform(MockMvcRequestBuilders.put("/stores/test").contentType(MediaType.APPLICATION_JSON)
.content(mapper.writeValueAsString(newStore))).andExpect(status().isNotFound());
}
#Test
#WithMockUser(roles = { "administrator" }, username = "myUser")
public void deleteStoreByAdmin() throws Exception {
// given
// a store in the system
ObjectMapper mapper = new ObjectMapper();
Mockito.when(storeTbl.delete(Mockito.anyString())).thenReturn(true);
Mockito.when(storeTbl.checkExist(Mockito.anyString())).thenReturn(true);
// when
Store newStore = new Store();
// admin get store list
// then
// System.out.println(storeTbl);
mvc.perform(MockMvcRequestBuilders.delete("/stores/test").contentType(MediaType.APPLICATION_JSON)
.content(mapper.writeValueAsString(newStore))).andExpect(status().isOk());
}
#Test
#WithMockUser(roles = { "administrator" }, username = "myUser")
// #WithUserDetails("sys#sys.com")
public void deleteStoreFailByAdmin() throws Exception {
// given
// a store in the system
ObjectMapper mapper = new ObjectMapper();
Mockito.when(storeTbl.delete(Mockito.anyString())).thenReturn(true);
Mockito.when(storeTbl.checkExist(Mockito.anyString())).thenReturn(false);
// when
Store newStore = new Store();
// admin get store list
// then
// System.out.println(storeTbl);
mvc.perform(MockMvcRequestBuilders.delete("/stores/test").contentType(MediaType.APPLICATION_JSON)
.content(mapper.writeValueAsString(newStore))).andExpect(status().is4xxClientError());
}
}
How to execute the mvn test with errors
Authentication Provider ->Yes
"Could not find artifact com.amazonaws:aws-java-sdk-bom:pom:2.15.4 in central"
To address this POM issue, please refer to the AWS Spring BOOT example applications that are located in https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/usecases.
They all work and use AWS SDK For Java Version 2. I have deployed every one of them to the Cloud by using Elastic BeanStalk. Furthermore, these Spring Boot example apps interact with different AWS services like DynamoDB, Amazon RDS, Amazon S3, Amazon SES, Amazon Rekognition, etc.
Creating your first AWS Java web application
Creating the DynamoDB web application item tracker
Creating the Amazon Relational Database Service item tracker
Creating an example AWS photo analyzer application using the AWS SDK
for Java
Once you are successful getting the apps to work using V2, then you can build some tests
Getting exception whilst using Google Pubsub to list topics, my web application is running on tomcat.
public static List<String> listTopics(GcpCredentials gcCredentials, String project) throws GCPException, IOException
{
List<String> topics = new ArrayList<>();
TopicAdminClient client = getTopicClient(gcCredentials);
ProjectName projectName = ProjectName.create(project);
ListTopicsPagedResponse response = client.listTopics(projectName);
for (Topic topic :response.iterateAll())
{
topics.add(topic.getNameAsTopicName().getTopic());
}
return topics;
}`
Exception:
java.lang.IllegalArgumentException: Jetty ALPN/NPN has not been properly configured.
at io.grpc.netty.GrpcSslContexts.selectApplicationProtocolConfig(GrpcSslContexts.java:174)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:151)
at io.grpc.netty.GrpcSslContexts.configure(GrpcSslContexts.java:139)
at io.grpc.netty.GrpcSslContexts.forClient(GrpcSslContexts.java:109)
at io.grpc.netty.NettyChannelBuilder.createProtocolNegotiatorByType(NettyChannelBuilder.java:335)
at io.grpc.netty.NettyChannelBuilder.createProtocolNegotiator(NettyChannelBuilder.java:308)
at io.grpc.netty.NettyChannelBuilder$NettyTransportFactory$DynamicNettyTransportParams.getProtocolNegotiator(NettyChannelBuilder.java:499)
at io.grpc.netty.NettyChannelBuilder$NettyTransportFactory.newClientTransport(NettyChannelBuilder.java:448)
at io.grpc.internal.CallCredentialsApplyingTransportFactory.newClientTransport(CallCredentialsApplyingTransportFactory.java:61)
at io.grpc.internal.InternalSubchannel.startNewTransport(InternalSubchannel.java:209)
at io.grpc.internal.InternalSubchannel.obtainActiveTransport(InternalSubchannel.java:186)
at io.grpc.internal.ManagedChannelImpl$SubchannelImplImpl.obtainActiveTransport(ManagedChannelImpl.java:806)
at io.grpc.internal.GrpcUtil.getTransportFromPickResult(GrpcUtil.java:568)
at io.grpc.internal.DelayedClientTransport.reprocess(DelayedClientTransport.java:296)
at io.grpc.internal.ManagedChannelImpl$LbHelperImpl$5.run(ManagedChannelImpl.java:724)
at io.grpc.internal.ChannelExecutor.drain(ChannelExecutor.java:87)
at io.grpc.internal.ManagedChannelImpl$LbHelperImpl.runSerialized(ManagedChannelImpl.java:715)
at io.grpc.internal.ManagedChannelImpl$NameResolverListenerImpl.onUpdate(ManagedChannelImpl.java:752)
at io.grpc.internal.DnsNameResolver$1.run(DnsNameResolver.java:174)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I have observed this problem with Netty version 4.1.15.Final but not with 4.1.13.Final. Check your transitive dependencies. I.e Spring Boot references Netty.
What I added to POM to make it work with Spanner API version 0.22.0-beta:
<properties>
<v.netty>4.1.13.Final</v.netty>
</properties>
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-http2</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler-proxy</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec-socks</artifactId>
<version>${v.netty}</version>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>${v.netty}</version>
</dependency>
</dependencies>
</dependencyManagement>
If the problem persists, or if it is not an option, plase run your JVM with appropriate bootclasspath entry, like:
java -Xbootclasspath/p:/tmp/alpn-boot-8.1.11.v20170118.jar -cp ...
Make sure to replace /tmp/alpn-boot-8.1.11.v20170118.jar with location of alpn jar that matches your JVM version as listed on this page: https://www.eclipse.org/jetty/documentation/9.4.x/alpn-chapter.html
There is a possible solution on github: "Exception when configuring SSL: "Jetty ALPN/NPN has not been properly configured."
The recommended steps, quoting from the above document:
1) Edit catalina.sh
/usr/local/Cellar/tomcat/8.5.3/libexec/bin/catalina.sh
2) At line 103, add the following
CATALINA_OPTS="-javaagent:/Library/Tomcat/lib/jetty-alpn-agent-2.0.6.jar"
3) Restart tomcat
../bin/shutdown.sh ../bin/startup.sh
I am trying to use gremlin to interact with my Neo4j community database. I am working in eclipse using maven.
Following the documentation in http://tinkerpop.apache.org/docs/3.1.0-incubating/#neo4j-gremlin i set up my dependencies to:
<dependencies>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-cypher</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ha</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>gremlin-core</artifactId>
<version>3.1.0-incubating</version>
</dependency>
<dependency>
<groupId>org.apache.tinkerpop</groupId>
<artifactId>neo4j-gremlin</artifactId>
<version>3.1.0-incubating</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-tinkerpop-api-impl</artifactId>
<version>0.1-2.2</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-tinkerpop-api</artifactId>
<version>0.1</version>
</dependency>
</dependencies>
After executing:
package test.gremlin.maven;
import org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph;
import org.apache.tinkerpop.gremlin.structure.Graph;
public class TestGremlin {
public static void main(String[] args) {
Graph graph = Neo4jGraph.open("/tmp/gremlintest");
}
}
i get the following error:
Exception in thread "main" java.lang.ClassCastException: org.neo4j.function.Functions$$Lambda$24/252651381 cannot be cast to org.neo4j.helpers.Function
at org.neo4j.helpers.Settings$DefaultSetting.apply(Settings.java:846)
at org.neo4j.kernel.configuration.ConfigurationValidator.validate(ConfigurationValidator.java:50)
at org.neo4j.kernel.configuration.Config.replaceSettings(Config.java:204)
at org.neo4j.kernel.configuration.Config.<init>(Config.java:92)
at org.neo4j.kernel.impl.factory.PlatformModule.<init>(PlatformModule.java:124)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.createPlatform(GraphDatabaseFacadeFactory.java:177)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:124)
at org.neo4j.kernel.impl.factory.CommunityFacadeFactory.newFacade(CommunityFacadeFactory.java:40)
at org.neo4j.kernel.impl.factory.GraphDatabaseFacadeFactory.newFacade(GraphDatabaseFacadeFactory.java:108)
at org.neo4j.graphdb.factory.GraphDatabaseFactory.newDatabase(GraphDatabaseFactory.java:130)
at org.neo4j.graphdb.factory.GraphDatabaseFactory$1.newDatabase(GraphDatabaseFactory.java:118)
at org.neo4j.graphdb.factory.GraphDatabaseBuilder.newGraphDatabase(GraphDatabaseBuilder.java:185)
at org.neo4j.tinkerpop.api.impl.Neo4jFactoryImpl.newGraphDatabase(Neo4jFactoryImpl.java:44)
at org.neo4j.tinkerpop.api.Neo4jFactory$Builder.open(Neo4jFactory.java:32)
at org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph.<init>(Neo4jGraph.java:131)
at org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph.open(Neo4jGraph.java:145)
at org.apache.tinkerpop.gremlin.neo4j.structure.Neo4jGraph.open(Neo4jGraph.java:154)
at test.gremlin.maven.TestGremlin.main(TestGremlin.java:10)
Can you try to use the latest release: which is 0.3-2.3.3
see: https://github.com/neo4j-contrib/neo4j-tinkerpop-api-impl/tree/0.3-2.3.3
I tried to connect using orientdb database with java. like this
OrientGraph odb = new OrientGraph("plocal:C:/Users/USER/Desktop/orientdb/databases/testJ", "admin", "admin");
Its showing an error
HTTP Status 500 - Handler processing failed; nested exception is java.lang.NoClassDefFoundError: com/orientechnologies/orient/core/db/record/ODatabaseRecord
My dependencies..
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-core</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-jdbc</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>com.tinkerpop</groupId>
<artifactId>pipes</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-core</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.tinkerpop.blueprints</groupId>
<artifactId>blueprints-orient-graph</artifactId>
<version>2.4.0</version>
</dependency>
help me to resolve the error..
thank you in advance
The ODatabaseRecord seems to be deprecated from new version. I made following changes to your code and it worked (remove all other dependencies).
pom
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-core</artifactId>
<version>2.0.8</version>
</dependency>
<dependency>
<groupId>com.orientechnologies</groupId>
<artifactId>orientdb-jdbc</artifactId>
<version>2.0.8</version>
</dependency>
Java Code
OrientGraphFactory ogf = new OrientGraphFactory(
"plocal:C:/Users/USER/Desktop/orientdb/databases/testJ", "admin", "admin");
OrientGraph og = ogf.getTx();
try {
System.out.println("Features = " + og.getFeatures());
} finally {
og.shutdown();
}
Note: I found clue here.