0

I downloaded Eclipse Luna and Tomcat 8.0.24 some months ago but I started using it. I've been creating a web app without Maven. I downloaded manually Jersey 2.23, Jersey media moxy 2.23, java-son 1.0 , jdbc mysql 5.x and sql2o 1.5.4. I'm starting to learn Angular and I successfully created one page without any issue.

I remember have added my jars manually in the Build Path of my project and I was forced to add them in the Deployment Assemblies also. Fine.

Since 2 weeks I didn't shutdown my laptop, just in sleep mode. But yesterday I did shutdown. Since then I suffered to make it work again. I use postman chrome to test my restful services and I received after the shutting down the 404 error.

I realized that I started to see the exception in the console:

java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer

I deleted my folders of tomcat and eclipse to start again from scratch desperately. However, I got the same issue. The last thing that I remember I was playing with, were these modified options.

  1. Double click in server from servers tab
  2. Change from Use workspace metadata to Use Tomcat installation
  3. Properties in Server
  4. Switch Location from metadata to localhost.server

It was thanks to these questions that I solved my issue:

Now, after "reinstalling" eclipse and tomcat, when I add the jars in the library tab, they are now added in deployment assemblies automatically. (Surprised)

According to the previous attached questions, I added all the jars in WEB-INF/lib from my workspace as also in the tomcat/wtpwebapps/myproject/WEB-INF/lib. If I don't do this, I won't be able to make it work. Postman finally gives me the desired output.

Nevertheless, I realized when I copy the jars manually through windows explorer, the console in Eclipse displays the tomcat restarting again. BUT I still see the exception: java.lang.ClassNotFoundException: org.glassfish.jersey.servlet.ServletContainer. At least I can run my project in the browser or in postman without any issue. Very strange.

I want to add a new User Library in Windows > Preferences > Java > Build Path > User Libraries, but my list is EMPTY!!! So...

Finally, my questions:

  • What's going on with Eclipse?
  • Why am I not able to see my user libraries previously added? enter image description here
  • Why do I still see the exception of glassfish.jersey in the console if I added the jars in the web-inf folder which makes it work apparently.
  • Why do I need to add the jars in web-inf, if when I see all the jars included in the Tomcat library all my jars are there because I forgot to mention that I added a folder called External in lib of my Tomcat folder.

enter image description here

enter image description here

For all these changes, I restarted Eclipse

Community
  • 1
  • 1
Maximus Decimus
  • 4,901
  • 22
  • 67
  • 95

1 Answers1

0

Instead of adding jars manually, use maven and let the maven manage dependency of jars. ClassNotFoundException occurs when you don't have a jar in the classpath. Maybe the package you are deploying on the server is not bundled correctly. Make sure you have jar bundled in your package or present in the classpath.

Another reason could be you have duplicate class files in two jars and the class your programme picking is not suitable.

Shreyas
  • 1
  • 1