| Author |
Multiple webapps on different ports
|
David Sheltby
Ranch Hand
Joined: Oct 19, 2011
Posts: 34
|
|
I've come across a few posts on how to setup the conf/server.xml to run webapps on different ports, but none that actually detail how to specify which webapp is running on which port. I have 4 apps, only one of which needs to run on its own port. I've added a new Service element to the server config (similar to http://www.coderanch.com/t/513088/Tomcat/configure-two-applications-different-ports#2321484). However when I start up tomcat, it seems to create two instances of each app, one for each port (I've observed my servlets init() being called twice). Is there any way to specify that one app run on one service, and the other three to run on the other service?
Thanks
|
 |
Karthik Shiraly
Ranch Hand
Joined: Apr 04, 2009
Posts: 364
|
|
|
Perhaps you have specified the same "appBase" directory for both. Each virtual host should get a separate "appBase" directory which will have only that host's WARs.
|
 |
David Sheltby
Ranch Hand
Joined: Oct 19, 2011
Posts: 34
|
|
Yes you're right. So you're saying i should do something like below, where the app which runs on a separate port can go into a new directory such as webapps/8080?
Thanks
|
 |
Karthik Shiraly
Ranch Hand
Joined: Apr 04, 2009
Posts: 364
|
|
The first host's appBase is a subdirectory of the second host's in that example. I'm not very sure how the second host behaves when it finds WAR's under a subdirectory of its appBase. You can try and see if it works ok.
What I do is I specify completely different directories (or peers at the same level) for each virtual host. Like "webapps-mydomain1" and "webapps-mydomain2" (which resolve to the absolute paths /var/lib/tomcat6/webapps-mydomain1 and /var/lib/tomcat6/webapps-mydomain2 on *nix systems).
|
 |
 |
|
|
subject: Multiple webapps on different ports
|
|
|