Don Rhummy
Don Rhummy

Reputation: 25810

How do I get Jersey 2.6 working with Tomcat 6 and Java 1.6?

I'm trying to use Jersey (verson 2.6) with Tomcat 6 running on Java 1.6. It should be possible but is throwing errors and I'm not sure how to configure it properly or what libs to include.

Jersey Libs I have: https://maven.java.net/content/repositories/releases/org/glassfish/jersey/bundles/jaxrs-ri/2.6/jaxrs-ri-2.6.tar.gz

This seems to indicate it can be made to work with Servlet 2.5 (which is what Tomcat 6 uses): https://jersey.java.net/documentation/latest/modules-and-dependencies.html

java.lang.NoSuchMethodError: jersey.repackaged.com.google.common.collect.Iterables.concat(Ljava/lang/Iterable;Ljava/lang/Iterable;)Ljava/lang/Iterable;
        org.glassfish.jersey.server.internal.ConfigHelper.getContainerLifecycleListener(ConfigHelper.java:86)
        org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:169)
        org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:358)
        javax.servlet.GenericServlet.init(GenericServlet.java:212)
        org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
        org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
        org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:861)
        org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:612)
        org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:503)
        java.lang.Thread.run(Thread.java:662)

Upvotes: 0

Views: 1186

Answers (1)

Don Rhummy
Don Rhummy

Reputation: 25810

To get this working properly, you need:

  1. The 2.6 Jersey files from https://maven.java.net/content/repositories/releases/org/glassfish/jersey/bundles/jaxrs-ri/2.6/jaxrs-ri-2.6.tar.gz

  2. Genson (Helps with JSON of objects that aren't "obvious" for JSON): http://owlike.github.io/genson/

  3. Include all those jars in your web-inf/lib folder (either directly, or via your IDE's compile/deploy configs)

  4. Make sure there's no other versions of ANY of the jars or their classes anywhere in the Web application's classpath (my IDE was retaining old versions of Guava)

Upvotes: 1

Related Questions