Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to deploy my spring web project to eclipse internal tomcat server.(java.lang.ClassNotFoundException on tomcat startup)

when I use an external tomcat everything is just fine. but I need to deploy my project on internal eclipse tomcat server in order to be able to use DCEVM class hot swapping. When I try to start tomcat server from within eclipse it says it is not able to find one of my service classes I mentioned in my spring security configuration file as a bean. I also tried to add the project to tomcat class path but it did not solve my problem.

UPDATE

I found out the problem is because when I deploy my web project to eclipse tomcat server, no .class is copied to:

C:\Users\Meysam\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\villapweb\WEB-INF\classes

in fact, this folder contains my src/java/main package structure but no .class is copied in it.

lib folder is fine though (e.g. all dependencies of maven and other stuff copies in the path it is supposed to)

I think there might be something wrong with m2e-wtp plugin. I dont know what!

I am using eclipse 4.3 BTW.

SOLVED

I Solved this issue following these steps:

  1. right click on project in eclipse > properties > project facets
  2. in the right panel select runtimes and select your target server. Apply and ok.
  3. in the server modules list right click on project module and click clean module work directory
  4. right click on the server itself and you can clean both server and tomcat work directory one after another
  5. if that didn't work, try project > clean and also toggle "build automatically" option under project menu item.

Thats it. tomcat now copies all .class files to the target server and you see no ClassNotFound exception as tomcat starts up.

like image 878
Meysam Feghhi Avatar asked Feb 18 '14 12:02

Meysam Feghhi


2 Answers

[Copied to answer section]

I Solved this issue following these steps:

  1. right click on project in eclipse > properties > project facets
  2. in the right panel select runtimes and select your target server. Apply and ok.
  3. in the server modules list
  4. right click on project module and click clean module work directory right click on the server itself and you can clean both server and tomcat work directory one after another
  5. if that didn't work, try project > clean and also toggle "build automatically" option under project

Thats it. tomcat now copies all .class files to the target server and you see no ClassNotFound exception as tomcat starts up.

like image 171
Soman Dubey Avatar answered Sep 23 '22 20:09

Soman Dubey


I've followed the steps on the answer but It still wouldn't work for me, so, besides doing these steps once, I've found that doing a refresh on the target after doing a clean install automatically triggers the "Republish" status on the server, so when the server is executed all changes on the compiled classes (new classes and changes to existing ones) are then copied to wtpwebapps when the server is started.

like image 35
Willie Zayas Avatar answered Sep 22 '22 20:09

Willie Zayas