• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Multiple webapps on different ports

 
David Sheltby
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1208
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 1208
25
Android C++ Java Linux PHP Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic