org.glassfish.jersey.servlet.ServletContainer ClassNotFoundException

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:

  <servlet-name>Jersey REST Service</servlet-name>
  <servlet-name>Jersey REST Service</servlet-name>

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:

<!-- if you are using Jersey client specific features without the server side -->

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:


public class ApplicationConfig extends Application {


For more information, check the Jersey documentation.

See also:

Leave a Comment