java.lang.NoSuchFieldError:创建泽西休息客户端的WADL_JSON

时间:2014-09-01 07:48:37

标签: java json rest jersey

我正在使用jersey rest创建jackson pojo mapping客户端。 这是代码spinet:

    ClientConfig clientConfig = new DefaultClientConfig();
    clientConfig.getClasses().add(JacksonJsonProvider.class);
    clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
    client = Client.create(clientConfig);
    webResource = client.resource("url to exposed rest web service");

此代码在第client = Client.create(clientConfig)

处抛出以下异常
Sep 01, 2014 12:42:04 PM com.sun.jersey.core.spi.component.ProviderFactory __getComponentProvider
SEVERE: The provider class, class com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$Wadl, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.NoSuchFieldError: WADL_JSON
    at com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$Wadl.<init>(JSONRootElementProvider.java:138)
    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 com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(ComponentConstructor.java:161)
    at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:141)
    at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:163)
    at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:134)
    at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:232)
    at com.sun.jersey.core.spi.component.ProviderServices.getProvidersAndServices(ProviderServices.java:149)
    at com.sun.jersey.core.spi.factory.MessageBodyFactory.initReaders(MessageBodyFactory.java:153)
    at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:145)
    at com.sun.jersey.api.client.Client.<init>(Client.java:275)
    at com.sun.jersey.api.client.Client.<init>(Client.java:150)
    at com.sun.jersey.api.client.Client.create(Client.java:476)
    at com.snapdeal.rnrs.client.RClient.<init>(RClient.java:29)
    at com.snapdeal.rnrs.client.RestClient.main(RestClient.java:45)

Sep 01, 2014 12:42:04 PM com.sun.jersey.core.spi.component.ProviderFactory __getComponentProvider
SEVERE: The provider class, class com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$Wadl, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.NoSuchFieldError: WADL_JSON
    at com.sun.jersey.json.impl.provider.entity.JSONRootElementProvider$Wadl.<init>(JSONRootElementProvider.java:138)
    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 com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(ComponentConstructor.java:161)
    at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:141)
    at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:163)
    at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:134)
    at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:232)
    at com.sun.jersey.core.spi.component.ProviderServices.getProvidersAndServices(ProviderServices.java:149)
    at com.sun.jersey.core.spi.factory.MessageBodyFactory.initWriters(MessageBodyFactory.java:171)
    at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:146)
    at com.sun.jersey.api.client.Client.<init>(Client.java:275)
    at com.sun.jersey.api.client.Client.<init>(Client.java:150)
    at com.sun.jersey.api.client.Client.create(Client.java:476)
    at com.snapdeal.rnrs.client.RClient.<init>(RClient.java:29)
    at com.snapdeal.rnrs.client.RestClient.main(RestClient.java:45)

我正在使用以下罐子:

  

杰克逊核-ASL:1.9.13
  杰克逊JAXRS:1.9.13
  杰克逊-XC:1.9.13
  jersey-client:1.1.5.1

我厌倦了搜索google and stackoverflow,但找不到任何解决方案。如果任何人遇到相同的错误并解决了问题,请提出一些解决方案。

1 个答案:

答案 0 :(得分:1)

我得到了问题的解决方案。这是由于jar冲突。 我将jersey-client:1.1.5.1更改为jersey-client:1.18