How can I deploy a web application to Tomcat from running the application

I would like to develop an updater application. Suppose I have:
- Launch Tomcat
- Launch the Updater application on Tomcat
- Launch the old version of the application on the same Tomcat

I would like to - Stop the old application
- Undeploy the old application
- Deploy the new version of the application (suppose I have a new file war with the application in the Updater application resource.

Is it possible to perform such a remote deployment on Tomcat from another application?

+3
source share
3 answers

Tomcat Server , :

"catalina- ant.jar" : {TOMCAT_PATH}\lib :


org.apache.catalina.ant.DeployTask task = new org.apache.catalina.ant.DeployTask();
task.setUrl("http://localhost:8084/manager");
task.setUsername("managerLogin");
task.setPassword("managerPassword");
task.setPath("/UrlToYourDeploadingProject");
task.setWar(new File("c:/Project.war").getAbsolutePath());
task.execute();

, .

+3

. (,.jar) Tomcat, ant, , . , , , ..; API, manager.

, ...

Apache : http://tomcat.apache.org/tomcat-5.5-doc/manager-howto.html#Executing Ant

... , : http://raibledesigns.com/wiki/Wiki.jsp?page=TomcatAntTasks

, ant. , ant, . , API.

ant: http://ant.apache.org/manual/tutorial-writing-tasks.html

, , API.

, API , .

manager Tomcat , -. WireShark Tomcat , manager. , jar .

+1

, undeploy/deploy .

, Maven2 "maven-deploy":

  • mvn : java
  • mvn package: ( webbapp)
  • mvn deploy: , , !

After that, you can associate this automation with a continuous integration server (for example, Hudson).

0
source

Source: https://habr.com/ru/post/1754997/


All Articles