开发者

NoSuchMethodError when accessing web app resource on Tomcat server

After searching online this is a question I have been unable to find an answer for. My Web Application is deployed to the tomcat server i know this is all working as the index.jsp displays the text. but when i try to access the resource i have made that should print out hello world the tomcat server returns this message

java.lang.NoSuchMethodError: com.sun.jersey.core.spi.component.ProviderServices.<init>(Lcom/sun/jersey/core/spi/factory/InjectableProviderFactory;Lcom/sun/jersey/core/spi/component/ProviderFactory;Ljava/util/Set;Ljava/util/Set;)V
    com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:450)
    com.sun.jersey.server.impl.application.WebApplicationImpl.initiate(WebApplicationImpl.java:383)
    com.sun.jersey.spi.container.servlet.ServletContainer.initiate(ServletContainer.java:377)
    com.sun.jersey.spi.container.servlet.ServletContainer$InternalWebComponent开发者_开发问答.initiate(ServletContainer.java:242)
    com.sun.jersey.spi.container.servlet.WebComponent.load(WebComponent.java:449)
    com.sun.jersey.spi.container.servlet.WebComponent.init(WebComponent.java:169)
    com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:281)
    com.sun.jersey.spi.container.servlet.ServletContainer.init(ServletContainer.java:442)
    javax.servlet.GenericServlet.init(GenericServlet.java:212)
    org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
    org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
    org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
    org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
    org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
    java.lang.Thread.run(Unknown Source)

Does any one have any ideas or clues as to why this is happening that will aid me in solving this?

Any help greatly appreciated Thanks Chris


My guess is that there is something wrong with tha jars in your classpath. Probably, you may have two different versions of jersey on your classpath or in WEB-INF/lib


you must be include the following jersey jars into your WEB-INF/lib folder

  • jersey-server-1.3.jar
  • asm-3.1.jar
  • jersey-core-1.3.jar
  • jersey-client-1.3.jar


I believe this is caused by a difference in version between "jersey-server" and "jersey-core" jars (also double check you don't accidentally have duplicate difference versions of those various jars in your WEB-INF/lib folder).

In my case we had bumped our jersey-client version, which had bumped the jersey-core version (a dependency), or something like that, whereas we called out a particular (older) jersey-server version, thus causing a mismatch (old jersey-server 1.0.2, new jersey-core 1.11).

Also

SEVERE: The provider class, class com.sun.jersey.core.impl.provider.xml.XMLStreamReaderContextProvider, could not be instantiated
Caused by: java.lang.NullPointerException
        at com.sun.jersey.core.impl.provider.xml.TransformerFactoryProvider.<init>(TransformerFactoryProvider.java:57)
        ... 44 more

I think same.

Also if jersey-core is at 1.0.2 and jersey-client is 1.11 same ProviderServices failiure.

Fix: make them all match.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜