1
votes

I'm trying to setup a REST client based on jersey 2. That client code needs to run in a Jetty 9 server (standalone, not embedded) and is supposed to retrieve/consume data from another service. My very basic first test call looks like this:

ClientBuilder.newClient().target("https://10.224.1.206:8443/axis/services/EndSystemWebService").path("getAll").request().get( String.class )

This call fails with the following error:

Exception in thread "MyApp" MultiException stack 1 of 1 org.glassfish.hk2.api.UnsatisfiedDependencyException: There was no object available for injection at SystemInjecteeImpl(requiredType=ServiceLocator,parent=JaxbAutoDiscoverable,qualifiers={},position=-1,optional=false,self=false,unqualified=null,186516043) at org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:75) at org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:945) at org.jvnet.hk2.internal.ServiceLocatorImpl.inject(ServiceLocatorImpl.java:980) at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1055) at org.jvnet.hk2.internal.ServiceLocatorImpl.createAndInitialize(ServiceLocatorImpl.java:1046) at org.glassfish.jersey.model.internal.CommonConfig.configureAutoDiscoverableProviders(CommonConfig.java:608) at org.glassfish.jersey.client.ClientConfig$State.configureAutoDiscoverableProviders(ClientConfig.java:364) at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:399) at org.glassfish.jersey.client.ClientConfig$State.access$000(ClientConfig.java:90) at org.glassfish.jersey.client.ClientConfig$State$3.get(ClientConfig.java:122) at org.glassfish.jersey.client.ClientConfig$State$3.get(ClientConfig.java:119) at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:340) at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:733) at org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:285) at org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:135) at org.glassfish.jersey.client.JerseyInvocation.(JerseyInvocation.java:105) at org.glassfish.jersey.client.JerseyInvocation.(JerseyInvocation.java:101) at org.glassfish.jersey.client.JerseyInvocation.(JerseyInvocation.java:92) at org.glassfish.jersey.client.JerseyInvocation$Builder.method(JerseyInvocation.java:420) at org.glassfish.jersey.client.JerseyInvocation$Builder.get(JerseyInvocation.java:316)

I'm not setting up my environment using Maven - doing it manually. So maybe there is something wrong with the libraries I'm using. Here they are:

enter image description here

Those are way too many by now but I kept adding them as I hoped that the issue would simply be due to a missing jar. It wasn't.

Any help is highly appreciated. Thanks

1
1. The error doesn't match up with the image of jars you provided. There error is saying that the ServiceLocator can't be injected in the JaxbAutoDiscoverable. Your image doesn't even show the jersey-media-jaxb jar where that class is in. 2. Your jar versions don't match up with the versions that come in the distribution, so I don't know where you getting them from. Specifically the HK2 version, which in the Jersey 2.22.1 distribution, should be 2.4.0-b031 - Paul Samsotha
3. Try and download the actual distribution (ri-bundle), and if you only need the client, have a look at this post for the minimum jars required. - Paul Samsotha
Thanks for the quick help! I removed all jersey-related jars, downloaded the official bundle you pointed me towards and used those instead. Works now! - Kurt
I would like to mark one of your comments as answer but the GUI doesn't allow me to. Seems to be FAD with stackoverflow. Shall I answer my own question instead so at least this is officially answered? I voted for your comments. - Kurt

1 Answers

2
votes

Thanks to the comments from peeskillet I downloaded the bundle from jersey, removed all the jars that I had previously added to my project, added the required jars out of the bundle (to avoid incompatibilities) and the error was gone. Thanks again!