Hi Folks, I'm currently trying to get the com.coreos.jetcd-core (an etcd client) working in a project that uses Karaf. Basically, in Karaf, the jetcd client can't resolve any hostnames. This is due to a call to ServiceLoader.load(URIResolver.class) in its SmartNameResolver.java class. My goal is to tell Karaf that it needs to use the SPI-Fly module to dynamically load the URIResolver implementations by modifying the MANIFEST.MF of jetcd-core-0.0.1.jar. For background, URIResolver.java defines the URIResolver interface. Another java file called URIResolvers.java contains two nested classes called Direct and DnsSrv which are the two existing implementations of URIResolver. Ideally, I need to load both implementations in order for the client to work for my use case.
I came across this post: http://aries.15396.n3.nabble.com/Apache-Aries-how-to-make-Osgi-work-with-ServiceLoader-td4033923.html#a4033945 which links to this SO post with a solution offered: https://stackoverflow.com/questions/39740531/jetty-websocket-java-lang-runtimeexception-cannot-load-platform-configurator Following up on that, I've made the following change to the jetcd-core manifest: Require-Capability:osgi.serviceloader;filter:="(osgi.serviceloader=com.coreos.jetcd.resolver.URIResolver)";resolution:=optional;cardinality:=multiple,osgi.extender;filter:="(osgi.extender=osgi.serviceloader.processor)"osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))" I've also tried this to see if I could get it to use only the Direct name resolver. Require-Capability:osgi.serviceloader;filter:="(osgi.serviceloader=com.coreos.jetcd.resolver.URIResolvers$Direct)";resolution:=optional;cardinality:=multiple,osgi.extender;filter:="(osgi.extender=osgi.serviceloader.processor)"osgi.ee;filter:="(&(osgi.ee=JavaSE)(version=1.8))" So far I've had no luck and I continue to get the same error in karaf: 2017-12-06 11:09:42,611 | WARN | fault-executor-0 | SmartNameResolver | 56 - com.foo.jetcd.example - 1.0.0.SNAPSHOT | Error wile getting list of servers com.coreos.jetcd.exception.EtcdException: Unable to resolve endpoints [http://0.0.0.0:2379] at com.coreos.jetcd.exception.EtcdExceptionFactory.newEtcdException(EtcdExceptionFactory.java:30) at com.coreos.jetcd.resolver.SmartNameResolver.doResolve(SmartNameResolver.java:135) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[:1.8.0_151] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)[:1.8.0_151] at java.lang.Thread.run(Thread.java:748)[:1.8.0_151] 2017-12-06 11:09:42,614 | WARN | fault-executor-0 | ManagedChannelImpl | 56 - com.foo.jetcd.example - 1.0.0.SNAPSHOT | [io.grpc.internal.ManagedChannelImpl-1] Failed to resolve name. status=Status{code=NOT_FOUND, description=null, cause=null} 2017-12-06 11:09:42,617 | ERROR | nsole user karaf | example | 56 - com.foo.jetcd.example - 1.0.0.SNAPSHOT | [com.foo.jetcd.example.JetcdClient(1)] The start method has thrown an exception java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: io.grpc.StatusRuntimeException: NOT_FOUND I'm wondering if anyone has some advice about what I might be doing wrong. I'm using Karaf 4.0.9 with Felix and my assumption is that all I need to do is change the manifest because Aires/SPI-Fly are loaded by default (though this could be entirely wrong). Cheers -- Sent from: http://aries.15396.n3.nabble.com/Aries-User-f15394.html
