Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to purge tomcat's cache when deploying a new .war file? Is there a config setting?

Tags:

java

tomcat

I have a simple hello, world servlet application that I am just playing around with, and pushing it out to my tomcat server on a VPS.

When I make a change to my code, and deploy it, tomcat doesn't serve the newly published code (even after starting the service again).

I stop the service, then push the new war file to /webapps/, and I make sure to delete the old exploded folder also.

When I re-start the server, it still serves the older codebase.

Is there a setting in the config to stop this behaviour?

Also, what folders would I have to delete? Please be specific (folders and paths) as I have tried deleting some and havent' gotten anywhere.

like image 454
Blankman Avatar asked Nov 02 '11 01:11

Blankman


People also ask

What happens when you deploy a WAR file?

Java web applications are usually packaged as WAR files for deployment. These files can be created on the command line or with an IDE, like Eclipse. After deploying the WAR file, Tomcat unpacks it and stores all the project files from the webapps directory in a new directory named after the project.

What is work folder in Tomcat?

The work directory, as its name suggests, is where Tomcat writes any files that it needs during run time, such as the generated servlet code for JSPs, the class files for the same after they are compiled, the serialized sessions during restarts or shutdowns (SESSIONS.


2 Answers

You can delete the "work" directory.

Are you sure it's not a browser caching issue?

like image 120
Dave Newton Avatar answered Sep 18 '22 20:09

Dave Newton


I'd add that in case of really odd behavior - where you spend a couple of hours saying WTF - try manually deleting the /webapps/yourwebapp/WEB-INF/classes directory. A java source file that was moved to another package will not have its compiled class file deleted - at least in the case of an exploded web-application on TC. This can seriously drive you crazy with unpredictable behavior, especially with an annotated servlet.

like image 27
Hal50000 Avatar answered Sep 22 '22 20:09

Hal50000