The problem:
java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer
indicates that you try to use the Jersey 2.x servlet, but you are supplying the Jersey 1.x libs.
For Jersey 1.x you have to do it like this:
com.sun.jersey.spi.container.servlet.ServletContainer
For more information check the Jersey 1.x documentation.
If you instead want to use Jersey 2.x then you’ll have to supply the Jersey 2.x libs. In a maven based project you can use the following:
For Jersey 2.x you don’t need to setup anything in your web.xml, it is sufficient to supply a class similar to this:
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath(“rest”)
public class ApplicationConfig extends Application {
}
For more information, check the Jersey documentation.
See also:
java.lang.ClassNotFoundException: com.sun.jersey.spi.container.servlet.ServletContainer
Jersey Services with Tomcat and Eclipse
ClassNotFoundException when starting tomcat
It’s an eclipse setup issue, not a Jersey issue.
From this thread ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer
Right click your eclipse project Properties -> Deployment Assembly -> Add -> Java Build Path Entries -> Gradle Dependencies -> Finish.
So Eclipse wasn’t using the Gradle dependencies when Apache was starting .