Umesh Awasthi
Umesh Awasthi

Reputation: 23587

Eclipse tomcat picking old files

I tried everything what came to my mind, but somehow things are not working out.I created two projects using maven

Initially i was using Maven command line (not eclipse) to build my java application by

mvn > install

and was using mvn >eclipse:clean and mvn > eclipse:eclipse to update dependencies.Things was working fine.Now i want to debug my Java-application (jar) inside web-application, so i stopped using maven build process and added my java application to project tab under configure build path.

I tried cleaning, building my web-application but somehow Tomcat is picking old file of my java application. I even cleared my Eclipse tomcat work directory and redeployed application but for no use.

Can anyone point me where i am doing wrong. I am using Eclipse Kepler Release version with embedded maven plugin.

Upvotes: 1

Views: 2475

Answers (3)

lordscales91
lordscales91

Reputation: 433

In case anyone is having a similar issue, I will share the procedure that I followed to fix it. First, I must say that in my case the changes in the java files were properly updated (which means it were compiled and properly copied to the deploy path). However, the resource files, such as property files, were not updated.

With the following procedure I managed to get the files updated properly, and might solve similar issues.

  • Disable automatic builds (uncheck Project > Build Automatically).
  • Click on Project > Clean and select the offending project(s). Keep the check to launch a build after the clean.
  • Refresh the project (click with secondary button on the project root to bring the context menu and select Refresh).
  • Perform a Maven clean package (You can create a Maven Run Configuration and type "clean package" without quotes in the Goals field)
  • Refresh the project again.
  • Clean the server. To do so, click on clean on the context menu of the offending server (in the Servers view).

It is a very tedious process, but if the steps are not reproduced properly it will probably not work.

Upvotes: 3

Aaron Digulla
Aaron Digulla

Reputation: 328604

The usual culprits:

  • There is a Tomcat process still running (restart fails because the port is already occupied). Make sure Tomcat did really stop.
  • Tomcat is loading classes from an unexpected place. Check your Tomcat config and the deployment descriptor (context.xml for your app).
  • During deployment to a running server, Eclipse couldn't replace all class files. This is usually due to a classloader leak. Use a profiler to find those.
  • Make sure that you don't have duplicates on the classpath. maven-duplicate-finder is your friend.

[EDIT] Try to load one of the offending classes with ClassLoader.getResources() (see this question). That gives you the absolute path which Tomcat uses to load the classes.

Upvotes: 0

Native_Mobile_Arch_Dev
Native_Mobile_Arch_Dev

Reputation: 777

Try the following:

  1. Deleting the file on the application server which hosts your web app.
  2. Review your Pox.xml and any other associated configuration files and ensure your build settings are correct.

Upvotes: 0

Related Questions