This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Single Tomcat instance supporting multiple applications

 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to deploy multiple web applications in tomcat 5.5. Both running on the same port:-

http://locahost:8080/A
http://locahost:8080/B

But only one of them is getting invoked when we run the application in the browser. For the other one (in this case B application) I am getting 404 error?

Do you know how we can make both the applications running successfully in the browser? If I use a separate tomcat instance for both applications then it is working fine.
Which I don’t want, I want to use a single tomcat instance in which 2 apps will be deployed & invoked successfully. Any ideas are welcome.

Thanks.
 
Marshal
Posts: 67451
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tomcat can handle that fine. If, and only if, it is configured correctly. But, since you haven't told us how you have it configured...
 
Rithanya Laxmi
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created 2 folders in webapps each containing the respective WAR file and in server.xml:-

<Service name="Catalina">
<Connector port="8000" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="${catalina.base}/conf/.keystore" keystorePass="xxxxx"
clientAuth="false" sslProtocol="TLS" />

<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>

<Host name="localhost" appBase="webapps/A"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine></Service>

<Service name="Catalina2">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="${catalina.base}/conf/.keystore" keystorePass="xxxxx"
clientAuth="false" sslProtocol="TLS" />

<Engine name="Catalina2" defaultHost="localhostnew">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>

<Host name="localhostnew" appBase="webapps/B"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>

</Server>

but still only one applicaton is running? Please clarify is there anything I need to configure which I have missed out?

 
Saloon Keeper
Posts: 22496
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should not define your Context elements in server.xml. That is very bad practice and has been discouraged by the Tomcat authors since about Tomcat3.

It's better to either make them individual files in TOMCAT_HOME/conf/Catalina/localhost or as META-INF/context.xml files in the WARs.

If you go the conf/Catalina/localhost route, note that the context path defined in the Context xml will be ignored and the actual context path will be derived from the name of the file containing the Context. So you'd have to name those files "A.xml" and "B.xml".

Your biggest problem, I think is that you attempted to define the webapps using the server.xml Host element when you should be using a Context element (but not in server.xml!) A Host can contain multiple Contexts, but you normally only have one Host, which by default would be named "localhost". It's what determines that the Context directory is conf/Catalina/localhost instead of conf/Catalina/xyz.
 
You're not going crazy. You're going sane in a crazy word. Find comfort in this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic