1

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.

Community
  • 1
  • 1
julius_am
  • 1,422
  • 2
  • 23
  • 42

2 Answers2

1

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.

Kutzi
  • 1,295
  • 1
  • 15
  • 19
  • Do you know which version I should use? Tried removing each of the versions I have and still getting an error (either the one I mentioned above or this one: java.lang.NoClassDefFoundError: com/google/common/base/Function). – julius_am Jul 28 '14 at 04:42
  • Seems you use 2 dependencies which each require a specific version of google collections which is not compatible with the respective other one. Fixing this is either impossible or very hard to do, so I cannot help you here. – Kutzi Jul 28 '14 at 16:34
0

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.

Community
  • 1
  • 1
julius_am
  • 1,422
  • 2
  • 23
  • 42