Jersey REST服务调用另一个Jersey REST服务时出错 - java.lang.IllegalArgumentException:参数类型不匹配

时间:2014-02-17 04:38:40

标签: rest jersey

我从另一个Jersey REST服务调用一个Jersey REST服务时出现以下错误。它们部署在不同的tomcats上。调用服务在Jersey版本1.16上运行并且调用服务在1.4上运行 当我使用Grizzly服务器在我的本地machin上部署我的调用服务时,一切正常但是当我在tomcat上部署它时,我正面临这个问题。

SEVERE: The provider class, class com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General, could not be instantiated. Processing will continue but the class will not be utilized
java.lang.IllegalArgumentException: argument type mismatch
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
        at com.sun.jersey.core.spi.component.ComponentConstructor._getInstance(ComponentConstructor.java:198)
        at com.sun.jersey.core.spi.component.ComponentConstructor.getInstance(ComponentConstructor.java:169)
        at com.sun.jersey.core.spi.component.ProviderFactory.__getComponentProvider(ProviderFactory.java:166)
        at com.sun.jersey.core.spi.component.ProviderFactory.getComponentProvider(ProviderFactory.java:137)
        at com.sun.jersey.core.spi.component.ProviderServices.getComponent(ProviderServices.java:256)
        at com.sun.jersey.core.spi.component.ProviderServices.getServices(ProviderServices.java:160)
        at com.sun.jersey.core.spi.factory.MessageBodyFactory.initWriters(MessageBodyFactory.java:207)
        at com.sun.jersey.core.spi.factory.MessageBodyFactory.init(MessageBodyFactory.java:163)
        at com.sun.jersey.api.client.Client.init(Client.java:326)
        at com.sun.jersey.api.client.Client.access$000(Client.java:118)
        at com.sun.jersey.api.client.Client$1.f(Client.java:189)
        at com.sun.jersey.api.client.Client$1.f(Client.java:185)
        at com.sun.jersey.spi.inject.Errors.processWithErrors(Errors.java:197)
        at com.sun.jersey.api.client.Client.<init>(Client.java:185)
        at com.sun.jersey.api.client.Client.<init>(Client.java:168)
        at com.sun.jersey.api.client.Client.create(Client.java:638)

...

Loaded com.sun.jersey.client.urlconnection.HttpURLConnectionFactory from file:/fmrkut3/apps/UAT3/venture/lib/jersey-client-1.4.jar]
[Loaded com.sun.jersey.api.client.ClientRequest from file:/fmrkut3/apps/UAT3/venture/lib/jersey-client-1.4.jar]
Feb 17, 2014 4:15:08 AM com.sun.jersey.spi.inject.Errors processErrorMessages
SEVERE: The following errors and warnings have been detected with resource and/or provider classes:
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.xml.SAXParserContextProvider(com.sun.jersey.core.util.FeaturesAndProperties) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.xml.XMLStreamReaderContextProvider(com.sun.jersey.core.util.FeaturesAndProperties) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.xml.DocumentBuilderFactoryProvider(com.sun.jersey.core.util.FeaturesAndProperties) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.xml.TransformerFactoryProvider(com.sun.jersey.core.util.FeaturesAndProperties) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$App(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$Text(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLRootElementProvider$General(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$App(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$Text(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLJAXBElementProvider$General(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$App(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$Text(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.XMLListElementProvider$General(com.sun.jersey.spi.inject.Injectable,javax.ws.rs.ext.Providers) at parameter index 0
  SEVERE: Missing dependency for constructor public com.sun.jersey.core.impl.provider.entity.DocumentProvider(com.sun.jersey.spi.inject.Injectable,com.sun.jersey.spi.inject.Injectable) at parameter index 0

1 个答案:

答案 0 :(得分:1)

如底部堆栈跟踪所示,您有一个缺少的库;如果我没有弄错的话,那就是

<dependency>
    <groupId>com.sun.jersey</groupId>
    <artifactId>jersey-core</artifactId>
    <version>1.16</version>
</dependency>

此库可能存在于您的本地配置中(或与Grizzly捆绑在一起),而不是Tomcat。