Meysam Feghhi
Meysam Feghhi

Reputation: 945

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.

Upvotes: 7

Views: 11183

Answers (4)

inor
inor

Reputation: 2846

I had almost the same problem - one of my projects did not make it to the deployment area (its jar). What i did is 1) remove the appliction from tomcat 2) clean tomcat work directory 3) most important: project - clean - all. Then i added the application again and... problem solved

Upvotes: 1

Foontik
Foontik

Reputation: 11

I had the same problem in Web Dynamic project converted to Maven project.

I found error in properties->Deployment Assembly->right panel. There was source=src folder and deploy path=WEB-INF/classes. Classes couldn't be found by Eclipse.

Changed to source=target/classes.

Upvotes: 0

Willie Zayas
Willie Zayas

Reputation: 11

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.

Upvotes: 1

Soman Dubey
Soman Dubey

Reputation: 3926

[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.

Upvotes: 8

Related Questions