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 !!
raju
Great, Its working for me. thanks
Aidar
how to fix this on Intellij IDEA
sushma
i am getting below issue
org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: com/sun/jna/Pointer.
Can any one help me with this?
Sunil sharma
Please check with the servlet-name name and param-name in web.xml once.
Pavan Segalla
After 3 days finally, I was able to fix the issue with the help of this blog. Thanks a lot
sandeep
Thanks a lot…
ranjit
worked perfectly.
Neha
In my project maven dependencies are already added but still I am getting the issue .please help me in resolving this.
Paulo
Do you remenber how you solved it?
Sangeetha
After wasting many hours in fixing this issue, finally I found this blog. Issue resolved. Thanks a lot.
Monika
Hi Lokesh, after clicking on next Java Build Path entries, there is nothing available and I am stuck there. Please do help.
Lokesh Gupta
Yours is maven project??
YassmeenSayed
thanks a lot , this saved my sanity.
Atula
perfectly worked, thanks a lot, you help me save many hours 🙂
Sandip
Thanks a lot trying for a day .Now working perfectly.
Sandeep
Thanks a lot. Had been trying to solve this problem for half a day. Perfectly worked.