Hi there!
I am running tomcat 7.0.14-embed with JavaSE-1.6 on a Windows7 machine.
/Autodeploy/, /DeployOnStartup/ and /UnpackWARs/ works like a charm when
creating a new WAR-File at appBase directory for the firsttime. If my
application generates a updated version of the WAR-File while the Tomcat
isn't running, the new WAR-File never gets unpacked. This behaviour is
also described at:
*
http://tomcat.apache.org/tomcat-6.0-doc/config/host.html#Automatic%20Application%20Deployment
/Note: If you re-deploy an updated WAR file while Tomcat is
stopped, be sure to delete the associated expanded directory
before restarting Tomcat, so that the updated WAR file will be
re-expanded when Tomcat restarts./
Is there a workarround to re-deploy a updated WAR-File, while Tomcat is
offline, without deleting folders manually?
Scenario:
1. my app generates a WAR File with a index.jsp and random image to
display (basically just a zip file)
2. my app starts tomcat 7 embedded
Current Behavior:
1. if the WAR-File was never deployed before, the WAR-File will be unpacked
2. if the WAR-File was deployed before, the WAR-File will not be
unpacked and the old version is visible in the webbrowser
In that case i have to delete the folder manually and restart tomcat.
Wished Behavior:
Everytime the WAR-File is updated it shall be re-deployed by Tomcat.
Code Snippet:
String tempDir = System.getProperty("java.io.tmpdir");
String appID = "test";
RandomWarGenerator rwg = new RandomWarGenerator(tempDir, appID);
rwg.export(); // generates WAR-File with index.jsp and random
image to display
File webApp = new File(tempDir, appID);
Tomcat server = new Tomcat();
server.setBaseDir(tempDir);
server.setPort(8080);
StandardHost stdHost = (StandardHost) server.getHost();
stdHost.setAppBase(tempDir);
stdHost.setUnpackWARs(true);
stdHost.setAutoDeploy(true);
stdHost.setDeployOnStartup(true);
server.setHost(stdHost);
server.addWebapp(server.getHost(), "/" + appID ,
webApp.getAbsolutePath());
server.start();
server.getServer().await();
Thanks in advance!
Cheers Darky