julius_am
julius_am

Reputation: 1527

NoSuchMethodError when using jersey 2.0

I'm using jersey 2.0 and when performing a request I'm getting the following exception:

SEVERE: StandardWrapper.Throwable
java.lang.NoSuchMethodError: com.google.common.collect.Sets.newIdentityHashSet()Ljava/util/Set;
    at org.glassfish.jersey.model.internal.CommonConfig.<init>(CommonConfig.java:215)
    at org.glassfish.jersey.server.ResourceConfig$State.<init>(ResourceConfig.java:107)
    at org.glassfish.jersey.server.ResourceConfig.<init>(ResourceConfig.java:338)
    at org.glassfish.jersey.servlet.WebComponent.createResourceConfig(WebComponent.java:373)
    at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:259)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:167)
    at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:349)
    at javax.servlet.GenericServlet.init(GenericServlet.java:160)
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1280)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1193)
    at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:865)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:136)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:310)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)

These are the jars I'm using:

enter image description here

I guess I have some problem with the jars I'm using but I can't figure out what is missing. I'm not using maven so I'm consuming the jars directly.

In addition, I'm also implementing a filter (ContainerResponseFilter) in my app, maybe it has something to do with the exception, I don't know.

Upvotes: 1

Views: 6927

Answers (2)

julius_am
julius_am

Reputation: 1527

I solved the problem. Basically my jars probably didn't match. This answer helped we a lot. You can find there a list of all required jars. I have the exact same list and it's working.

Upvotes: 0

Kutzi
Kutzi

Reputation: 1321

This is probably caused by different, incompatible versions of Google Collections (now part of Guava) in your dependencies. The Jersey library was compiled against one version of this and now during runtime a different version of it is loaded first. Try excluding one of google-collections or guava-collections from your dependencies.

Upvotes: 1

Related Questions