gpt4 book ai didi

java.lang.NoSuchFieldError : WADL_JSON in creating jersey rest client

转载 作者:太空宇宙 更新时间:2023-11-04 06:34:33 24 4
gpt4 key购买 nike

我正在使用 jackson pojo 映射 创建 jersey rest 客户端。这是代码 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)

我正在使用以下 jar :

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

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

最佳答案

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

关于java.lang.NoSuchFieldError : WADL_JSON in creating jersey rest client,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25601098/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com