aspose file tools*
The moose likes Tomcat and the fly likes Single Tomcat instance supporting multiple applications Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Single Tomcat instance supporting multiple applications" Watch "Single Tomcat instance supporting multiple applications" New topic
Author

Single Tomcat instance supporting multiple applications

Rithanya Laxmi
Ranch Hand

Joined: Jan 24, 2011
Posts: 136
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.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

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...


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Rithanya Laxmi
Ranch Hand

Joined: Jan 24, 2011
Posts: 136
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?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
 
subject: Single Tomcat instance supporting multiple applications