File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Single Tomcat instance supporting multiple applications

 
Rithanya Laxmi
Ranch Hand
Posts: 184
  • 0
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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: 184
  • 0
  • 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?

 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic