bitsofinfo / hazelcast-docker-swarm-discovery-spi

Docker Swarm based discovery strategy SPI for Hazelcast enabled applications
Apache License 2.0
39 stars 33 forks source link

Cannot create a new instance of MemberAddressProvider 'class #12

Closed rhipolito closed 6 years ago

rhipolito commented 6 years ago

Getting this error with swarm discovery SPI. DNSRR mode works. Any ideas as to why we see this error? Mar 01, 2018 2:14:37 PM com.hazelcast.config.XmlConfigLocator

INFO: Loading configuration /usr/local/hazelcast/conf/hazelcast.xml from System property 'hazelcast.config'

Mar 01, 2018 2:14:37 PM com.hazelcast.config.XmlConfigLocator

INFO: Using configuration file at /usr/local/hazelcast/conf/hazelcast.xml

Exception in thread "main" com.hazelcast.config.ConfigurationException: Cannot create a new instance of MemberAddressProvider 'class org.bitsofinfo.hazelcast.discovery.docker.swarm.SwarmMemberAddressProvider'

at com.hazelcast.instance.DefaultNodeContext.newMemberAddressProviderInstance(DefaultNodeContext.java:101)

at com.hazelcast.instance.DefaultNodeContext.createAddressPicker(DefaultNodeContext.java:71)

at com.hazelcast.instance.Node.(Node.java:182)

at com.hazelcast.instance.HazelcastInstanceImpl.createNode(HazelcastInstanceImpl.java:160)

at com.hazelcast.instance.HazelcastInstanceImpl.(HazelcastInstanceImpl.java:128)

at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:195)

at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:174)

at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:124)

at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:58)

at com.hazelcast.core.server.StartServer.main(StartServer.java:46)

Caused by: java.lang.reflect.InvocationTargetException

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at com.hazelcast.instance.DefaultNodeContext.newMemberAddressProviderInstance(DefaultNodeContext.java:89)

... 9 more

Caused by: java.lang.NoClassDefFoundError: com/spotify/docker/client/DockerCertificatesStore

at org.bitsofinfo.hazelcast.discovery.docker.swarm.SwarmMemberAddressProvider.initialize(SwarmMemberAddressProvider.java:101)

at org.bitsofinfo.hazelcast.discovery.docker.swarm.SwarmMemberAddressProvider.(SwarmMemberAddressProvider.java:70)

... 14 more

Caused by: java.lang.ClassNotFoundException: com.spotify.docker.client.DockerCertificatesStore

at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)

at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

... 16 more

This is our compose file.

what should this value be? - HZ_SWARM_MGR_URI=http://10.7.159.180:80 Do we need a cert imported into the hazelcast container? should it be a different port?

version: '3.2' services: devhazelcast: image: fx-docker-dev.ppe.mdrxdev.com/nanthealth/alpine-java8-hazelcast:1.3.0-SNAPSHOT-20180222.100929-496 deploy: replicas: 2 resources: limits: cpus: '1' memory: 2G restart_policy: condition: on-failure ports:

networks: xppe_dev_default: external: name: ppe_dev_default volumes: vol_hzdevnfs: external: true

bitsofinfo commented 6 years ago

Caused by: java.lang.NoClassDefFoundError: com/spotify/docker/client/DockerCertificatesStore

This is caused when there is a class file that your code depends on and it is present at compile time but not found at runtime. Look for differences in your build time and runtime classpaths.

What version of java are you running? Do you have another version of the spotify docker lib on your class path or something?

rhipolito commented 6 years ago

we are running openjdk 1.8 and the path is PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/bin:/usr/local/hazelcast

i no longer see the errors about the docker client. we previously didnt include the docker client. we have rebuilt and deployed and still see this error.

were we have all jars in /usr/local/hazelcast

INFO: Using configuration file at /usr/local/hazelcast/conf/hazelcast.xml

Exception in thread "main" com.hazelcast.config.ConfigurationException: Cannot create a new instance of MemberAddressProvider 'class org.bitsofinfo.hazelcast.discovery.docker.swarm.SwarmMemberAddressProvider'

at com.hazelcast.instance.DefaultNodeContext.newMemberAddressProviderInstance(DefaultNodeContext.java:101)

bitsofinfo commented 6 years ago

Are you using gradle or maven in your application that includes this library?

if so please provide a dependencies dump from gradle/maven

Also your stack trace above is incomplete, need to see the full trace

rhipolito commented 6 years ago

first, thank you for the help!! we are using maven. ill need to get our developer to get more info if this isnt enough.

`

com.hazelcast hazelcast-all ${hazelcast.version}
    <dependency>
        <groupId>org.bitsofinfo</groupId>
        <artifactId>hazelcast-docker-swarm-discovery-spi</artifactId>
        <version>${swarm.spi.version}</version>
    </dependency>
    <dependency>
      <groupId>com.spotify</groupId>
      <artifactId>docker-client</artifactId>
      <version>${docker-client.version}</version>
    </dependency>        
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>${guava.version}</version>
    </dependency>`

here is the full stack trace. Mar 06, 2018 2:30:33 PM com.hazelcast.config.XmlConfigLocator

INFO: Loading configuration /usr/local/hazelcast/conf/hazelcast.xml from System property 'hazelcast.config'

Mar 06, 2018 2:30:33 PM com.hazelcast.config.XmlConfigLocator

INFO: Using configuration file at /usr/local/hazelcast/conf/hazelcast.xml

Exception in thread "main" com.hazelcast.config.ConfigurationException: Cannot create a new instance of MemberAddressProvider 'class org.bitsofinfo.hazelcast.discovery.docker.swarm.SwarmMemberAddressProvider'

at com.hazelcast.instance.DefaultNodeContext.newMemberAddressProviderInstance(DefaultNodeContext.java:101)

at com.hazelcast.instance.DefaultNodeContext.createAddressPicker(DefaultNodeContext.java:71)

at com.hazelcast.instance.Node.(Node.java:182)

at com.hazelcast.instance.HazelcastInstanceImpl.createNode(HazelcastInstanceImpl.java:160)

at com.hazelcast.instance.HazelcastInstanceImpl.(HazelcastInstanceImpl.java:128)

at com.hazelcast.instance.HazelcastInstanceFactory.constructHazelcastInstance(HazelcastInstanceFactory.java:195)

at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:174)

at com.hazelcast.instance.HazelcastInstanceFactory.newHazelcastInstance(HazelcastInstanceFactory.java:124)

at com.hazelcast.core.Hazelcast.newHazelcastInstance(Hazelcast.java:58)

at com.hazelcast.core.server.StartServer.main(StartServer.java:46)

Caused by: java.lang.reflect.InvocationTargetException

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at com.hazelcast.instance.DefaultNodeContext.newMemberAddressProviderInstance(DefaultNodeContext.java:89)

... 9 more

Caused by: java.lang.NumberFormatException: null

at java.lang.Integer.parseInt(Integer.java:542)

at java.lang.Integer.valueOf(Integer.java:766)

at org.bitsofinfo.hazelcast.discovery.docker.swarm.SwarmMemberAddressProvider.(SwarmMemberAddressProvider.java:58)

... 14 more

bitsofinfo commented 6 years ago

Yes, please have your developer interact directly on here, the exception you posted above is now a different one.

You should try including the shaded version of the docker-client library such as

compile group: 'com.spotify', name: 'docker-client', version: '8.+', classifier: 'shaded'

Please provide a sample project that demonstrates the error

kevinmoe211 commented 6 years ago

We are using Maven and are including the following dependencies

com.hazelcast hazelcast-all ${hazelcast.version}
    <dependency>
        <groupId>org.bitsofinfo</groupId>
        <artifactId>hazelcast-docker-swarm-discovery-spi</artifactId>
        <version>${swarm.spi.version}</version>
    </dependency>
    <dependency>
      <groupId>com.spotify</groupId>
      <artifactId>docker-client</artifactId>
      <version>${docker-client.version}</version>
    </dependency>        

We can try using the shaded version and let you know. We are just trying to run hazelcast version 3.9.1 using its own start cmd inside the container.

java $JAVA_OPTS -Dhz.public.host=getent hosts $HOST | awk '{print $1}' -cp "hazelcast-all.jar:hazelcast-docker-swarm-discovery-spi.jar:docker-client.jar:guava.jar" com.hazelcast.core.server.StartServer

We are not creating a new instance of hazelcast, maybe thats the problem and we need to do that?

kevinmoe211 commented 6 years ago

Also these are the versions of the dependencies.

1.0-RC6 3.9.1 8.11.1 Thanks again for your help!
bitsofinfo commented 6 years ago

Please provide a sample project that demonstrates the error

bitsofinfo commented 6 years ago

No response