We can face this exception if we are setting up jersey 2 project first time in eclipse using the Maven plugin.
The error message is simple enough to identify the root cause that the Jersey libraries are not in classpath.
The Error
The exception will look like this.
SEVERE: Servlet /JerseyDemos threw load() exception java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1559) at org.apache.catalina.core.DefaultInstanceManager.loadClass(DefaultInstanceManager.java:532) at org.apache.catalina.core.DefaultInstanceManager.loadClassMaybePrivileged(DefaultInstanceManager.java:514) at org.apache.catalina.core.DefaultInstanceManager.newInstance(DefaultInstanceManager.java:133) at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1137) at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:1081) at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:5027) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5314) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
Solution – Add Jersey Library in Deployment Assembly
Open your project’s deployment assembly configuration.

Add Build path jar files in assembly so that they can be added to lib folder in the final .war file.

The updated assembly will look like this.

Now when you again run the project after building it, this will run fine and will be able to find org.glassfish.jersey.servlet.ServletContainer class.
Happy Learning !!
Thanks you, it work for me.
which specific jars required can you tell me ? i am using jdk21 and tomcat 11
Its quite old article. Maybe 10 yrs old. Today any IDE can handle the classpath just fine. Between, I was talking about all the jersey related Jar files in the lib folder, if you have placed these jars manually.
Great, Its working for me. thanks
how to fix this on Intellij IDEA
i am getting below issue
org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: com/sun/jna/Pointer.
Can any one help me with this?
Please check with the servlet-name name and param-name in web.xml once.
After 3 days finally, I was able to fix the issue with the help of this blog. Thanks a lot
Thanks a lot…
worked perfectly.
In my project maven dependencies are already added but still I am getting the issue .please help me in resolving this.
Do you remenber how you solved it?
did you solved it?
After wasting many hours in fixing this issue, finally I found this blog. Issue resolved. Thanks a lot.
Hi Lokesh, after clicking on next Java Build Path entries, there is nothing available and I am stuck there. Please do help.
Yours is maven project??
thanks a lot , this saved my sanity.
perfectly worked, thanks a lot, you help me save many hours :)
Thanks a lot trying for a day .Now working perfectly.
Thanks a lot. Had been trying to solve this problem for half a day. Perfectly worked.