You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Dark Before Dawn <da...@gmail.com> on 2011/06/14 00:57:24 UTC

[Embedded Tomcat 7] - Redeploy WAR File

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


Re: [Embedded Tomcat 7] - Redeploy WAR File

Posted by Dark Before Dawn <da...@gmail.com>.
Am 14.06.2011 01:01, schrieb Mark Thomas:
> On 13/06/2011 23:57, Dark Before Dawn wrote:
>> 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?
> The simplest is probably use unpackWARs=false
>
> Mark
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
Hi Mark,
that would be an option, but this could be a heavy footprint if 
WAR-Files grow in size?
Cheers

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: [Embedded Tomcat 7] - Redeploy WAR File

Posted by Mark Thomas <ma...@apache.org>.
On 13/06/2011 23:57, Dark Before Dawn wrote:
> 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?

The simplest is probably use unpackWARs=false

Mark



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org