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

4

7

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.

Epigrammatize answered 18/2, 2014 at 12:50 Comment(0)
H
8

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

Headspring answered 10/8, 2014 at 20:41 Comment(2)
Thank you! This worked for me. However I'm curious if anyone knows why a project would not have this configuration by default. I've used Eclipse for more than ten years and it's the first time I've even heard of the "Project Facets" configuration page. This is the first time I've used the Spring version of Eclipse so maybe that's why I'm having this problem.Roddy
You mentioned the "Server Modules List and Project Module". Can you please tell me where it is located?Ursala
F
1

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.

Forgather answered 28/5, 2015 at 14:57 Comment(0)
S
1

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

Subjunction answered 15/8, 2017 at 7:45 Comment(0)
B
0

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.

Bullard answered 6/10, 2016 at 11:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.