Jersey客户端:hk2 UnsatisfiedDependencyException

时间:2016-01-22 17:39:00

标签: rest jetty jersey-2.0 jersey-client hk2

我正在尝试基于jersey 2设置REST客户端。该客户端代码需要在Jetty 9服务器(独立,非嵌入式)中运行,并且应该检索/使用来自其他服务的数据。 我非常基本的第一次测试调用如下:

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

此调用失败,并显示以下错误:

  

线程中的异常" MyApp" MultiException堆栈1 of 1   org.glassfish.hk2.api.UnsatisfiedDependencyException:SystemInjecteeImpl没有可用于注入的对象(r​​equiredType = ServiceLocator,parent = JaxbAutoDiscoverable,qualifiers = {},position = -1,optional = false,self = false,unqualified = null, 186516043)           在org.jvnet.hk2.internal.ThreeThirtyResolver.resolve(ThreeThirtyResolver.java:75)           在org.jvnet.hk2.internal.Utilities.justInject(Utilities.java:945)           在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)           在org.glassfish.jersey.model.internal.CommonConfig.configureAutoDiscoverableProviders(CommonConfig.java:608)           在org.glassfish.jersey.client.ClientConfig $ State.configureAutoDiscoverableProviders(ClientConfig.java:364)           在org.glassfish.jersey.client.ClientConfig $ State.initRuntime(ClientConfig.java:399)           在org.glassfish.jersey.client.ClientConfig $ State.access $ 000(ClientConfig.java:90)           在org.glassfish.jersey.client.ClientConfig $ State $ 3.get(ClientConfig.java:122)           在org.glassfish.jersey.client.ClientConfig $ State $ 3.get(ClientConfig.java:119)           at org.glassfish.jersey.internal.util.collection.Values $ LazyValueImpl.get(Values.java:340)           在org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:733)           在org.glassfish.jersey.client.ClientRequest.getConfiguration(ClientRequest.java:285)           在org.glassfish.jersey.client.JerseyInvocation.validateHttpMethodAndEntity(JerseyInvocation.java:135)           在org.glassfish.jersey.client.JerseyInvocation。(JerseyInvocation.java:105)           在org.glassfish.jersey.client.JerseyInvocation。(JerseyInvocation.java:101)           在org.glassfish.jersey.client.JerseyInvocation。(JerseyInvocation.java:92)           在org.glassfish.jersey.client.JerseyInvocation $ Builder.method(JerseyInvocation.java:420)           在org.glassfish.jersey.client.JerseyInvocation $ Builder.get(JerseyInvocation.java:316)

我没有使用Maven设置环境 - 手动完成。所以我可能使用的库可能有问题。他们在这里:

enter image description here

现在这些太多了,但是我一直在添加它们,因为我希望这个问题只是因为缺少了jar。它不是。

非常感谢任何帮助。感谢

1 个答案:

答案 0 :(得分:2)

感谢peeskillet的评论我从jersey下载了包,删除了我之前添加到项目中的所有jar,从包中添加了所需的jar(以避免不兼容),错误是不见了。再次感谢!