Bug 57701

Summary: Implement "[Redeploy]" button for a web application
Product: Tomcat 8 Reporter: Konstantin Kolinko <knst.kolinko>
Component: ManagerAssignee: Tomcat Developers Mailing List <dev>
Status: NEW ---    
Severity: enhancement CC: boaglio, dilexie
Priority: P2 Keywords: PatchAvailable
Version: 8.0.20   
Target Milestone: ----   
Hardware: PC   
OS: All   
Attachments: Patch to provide "redeploy" button on Tomcat Web Application Manager.
Patch to provide "redeploy" functionality in Tomcat Manager
Patch to provide "redeploy" functionality in Tomcat Manager (Amended)

Description Konstantin Kolinko 2015-03-13 13:52:21 UTC
In Tomcat manager HTML interface for each web application (except the Manager app itself) there is a "Reload" button. I think that it would be nice to add a "Redeploy" button there, that will allow to trigger a redeployment of a web application.

Currently if the server is configured with autoDeploy="true", the redeployment can be triggered by touching the context file of the application (or the global conf/context.xml file if the application does not have one and does not have a war file). If autoDeploy="false" you are out of this option.

I expect the behaviour of this feature to be effectively the same as the one caused by touching the context file.  I would like this to be available in Tomcat 7.

Comment 1 Fernando Boaglio 2015-05-18 01:31:19 UTC
Created attachment 32741 [details]
Patch to provide "redeploy" button on Tomcat Web Application Manager.
Comment 2 Fernando Boaglio 2015-05-18 01:33:40 UTC
Patch to provide "redeploy" button on Tomcat Web Application Manager. 

I hope you like it =)
Comment 3 Mark Thomas 2015-05-26 19:05:06 UTC
I'm not convinced of the need for this feature but I don't object to it being added.

Overall the patch looks good. There is the odd s/reload/redploy/ required but that looks like copy/paste errors and is easily fixed.

I'm more concerned that the actual redeploy code is not correct. The issues I could see from a code inspection (I haven't tried applying the patch) are:
 - it assumes that the web application is deployed as a WAR
 - it assumes autoDeployment is enabled
 - it doesn't mark the web application as being serviced

I'd expect to see the following:
 - the context marked as serviced
 - the context removed from the host
 - check() being used to redeploy it
 - the serviced mark removed from the host
Comment 4 Bruno P. Kinoshita 2015-08-11 09:28:47 UTC
>I'm not convinced of the need for this feature but I don't object to it being added.

I used to see some Spring applications keeping objects in memory, and sometimes I had to restart Tomcat or redeploy the application. It was some years ago, and I don't have any Spring application in a Tomcat server (running mostly REST apps with Jersey), but maybe it would be a valid use case for this patch? Just my 0.02 cents
Comment 5 Dylan Lexie 2016-07-28 17:30:57 UTC
Created attachment 34076 [details]
Patch to provide "redeploy" functionality in Tomcat Manager

This patch is based on the work of Fernando Boaglio but addresses the issues raised by Mark Thomas. Removing the context from the host (as in, host.removeChild) was not sufficient, as the logic invoked by check() deals with protected/private members of a hostConfig. To complete this functionality, I saw no better option than to expose a public version of HostConfig.undeploy.

In addition to redeploy support in the HTML manager, this patch adds the redeploy command to the text manager and a redeploy ant task for the ant-based text manager wrapper. Maintaining consistency between these closely related utilities seems to be a more coherent update than just literally fulfilling the feature request.

Since the issue parameters state Tomcat 8.0, I worked from 8.0.x trunk. However, I share the OP's wish to see this feature in Tomcat 7. Is there a "right" way to try to facilitate this? For instance, would it be at all appropriate to re-mark the issue pertinent to 7 and instead provide a patch (which might be identical) for that version?
Comment 6 Dylan Lexie 2016-07-29 13:16:02 UTC
Created attachment 34079 [details]
Patch to provide "redeploy" functionality in Tomcat Manager (Amended)

Apologies, the patch I previously uploaded was generated with the new source file for RedeployTask not added. This amendment fixes that. See above for other notes.