How to start/stop an application from a webapplication running both on same tomcat

♀尐吖头ヾ 提交于 2020-01-17 05:43:08

问题


I need some help: I have two .war files running on tomcat 7, one is a webapplication, the other one is just a "normal" java application. Now I want to figure out how to start/stop the application from my webapplication. Both applications are on the same tomcat. Operation system is Ubuntu 14.04.

Thanks for your help


回答1:


you can configure that in your server.xml file and put 2 services :

<Service name="app1">
   <Connector port="8081" protocol="org.apache.coyote.http11.Http11NioProtocol" 
           connectionTimeout="20000" 
           redirectPort="8443" />
   <Engine name="Catalina" defaultHost="localhost">
      <Host name="localhost"  appBase="app1"
        unpackWARs="true" autoDeploy="true">
      </Host>
   </Engine>
</Service>
<Service name="app2">
   <Connector port="8082" protocol="org.apache.coyote.http11.Http11NioProtocol" 
           connectionTimeout="20000" 
           redirectPort="8443" />
   <Engine name="Catalina" defaultHost="localhost">
      <Host name="localhost"  appBase="app2"
        unpackWARs="true" autoDeploy="true">
      </Host>
   </Engine>
</Service>

Then the application will run on

  1. app1 on http://localhost:8081
  2. app2 on http://localhost:8082

Resource Link:

  1. Listen Multiple Ports in Tomcat
  2. How to run different apps on single Tomcat instance behind different ports?


来源:https://stackoverflow.com/questions/37807422/how-to-start-stop-an-application-from-a-webapplication-running-both-on-same-tomc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!