java – 在osgi中使用球衣客户端时出错 – 没有提供生成器

前端之家收集整理的这篇文章主要介绍了java – 在osgi中使用球衣客户端时出错 – 没有提供生成器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我尝试从泽西客户端创建一个WebTarget时,我得到以下异常.

我的代码

Client client = ClientBuilder.newClient();
WebTarget baseTarget = client.target("http://127.0.0.1:9000");

异常堆栈跟踪

java.lang.IllegalStateException: No generator was provided
and there is no default generator registered
    at    org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.internalCreate(ServiceLocatorFactoryImpl.java:266)
    at org.glassfish.hk2.internal.ServiceLocatorFactoryImpl.create(ServiceLocatorFactoryImpl.java:247)
    at org.glassfish.jersey.internal.inject.Injections._createLocator(Injections.java:138)
    at org.glassfish.jersey.internal.inject.Injections.createLocator(Injections.java:109)
    at org.glassfish.jersey.internal.RuntimeDelegateImpl.<init>(RuntimeDelegateImpl.java:61)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at java.lang.Class.newInstance(Class.java:374)
    at javax.ws.rs.ext.FactoryFinder.newInstance(FactoryFinder.java:118)
    at javax.ws.rs.ext.FactoryFinder.find(FactoryFinder.java:225)
    at javax.ws.rs.ext.RuntimeDelegate.findDelegate(RuntimeDelegate.java:135)
    at javax.ws.rs.ext.RuntimeDelegate.getInstance(RuntimeDelegate.java:120)
    at javax.ws.rs.core.UriBuilder.newInstance(UriBuilder.java:95)
    at javax.ws.rs.core.UriBuilder.fromUri(UriBuilder.java:119)
    at org.glassfish.jersey.client.JerseyWebTarget.<init>(JerseyWebTarget.java:71)
    at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:185)
    at org.glassfish.jersey.client.JerseyClient.target(JerseyClient.java:70)

可能是什么问题?

解决方法

将Jersey-ext目录中的以下存档添加到您的类路径中:

HK2-API – *罐子

HK2定位器 – *罐子

HK2-utils的 – *罐子

使用javax-注射 – *罐子

新泽西州番石榴 – *罐子

猜你在找的Java相关文章