• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Multiple webapps on different ports

 
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
 
Bartender
Posts: 1210
25
Android Python PHP C++ Java Linux
  • 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: 1210
25
Android Python PHP C++ Java Linux
  • 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).
 
I will suppress my every urge. But not this shameless plug:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!