java.lang.NoSuchFieldError: WADL_JSON in creating

2019-08-10 19:12发布

I am creating jersey rest client with jackson pojo mapping. here is code 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");

This code is throwing following exception at line 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)

I am using following jars:

jackson-core-asl:1.9.13
jackson-jaxrs:1.9.13
jackson-xc:1.9.13
jersey-client:1.1.5.1

I am fed up searching google and stackoverflow, but could not find any solution. Please suggest some solution if any one faced the same error and solved the problem.

1条回答
Melony?
2楼-- · 2019-08-10 19:40

I got the solution of the problem. It was due to jar conflicts. I change jersey-client:1.1.5.1 to jersey-client:1.18

查看更多
登录 后发表回答