NoSuchMethodError when accessing web app resource on Tomcat server

别来无恙 提交于 2019-12-20 02:33:07

问题


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


回答1:


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




回答2:


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



回答3:


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.



来源:https://stackoverflow.com/questions/4266592/nosuchmethoderror-when-accessing-web-app-resource-on-tomcat-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!