Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Different webapps on same instance of tomcat on different ports

 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a web application deployed and running on Tomcat at port 8080. Shutdown port is 8005 and AJP Connector is on Port 8009. I want to deploy another application on SAME INSTANCE and run it at different port. Convinced that it is possible, I made following changes in my $CATALINA_HOME/conf/server.xml:

Uncommented following in the xml file:
<Connector port="8443" maxHttpHeaderSize="8192"
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" disableUploadTimeout="true"
acceptCount="100" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" />

Now how to deploy my second application so that it listens to 8443 and not at 8080. Which ever application starts first takes 8080 and second application complains of busy port.

Can someone please tell me the procedure of configuring tomcat to run different applications on different ports?
Thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to deploy my second application so that it listens to 8443


It is the connector that is going to listen at that port, not your application. 8443 is the default SSL port when Tomcat default server.xml is used so https requests will go there automatically.

Why do you have an AJP connector at all?

If you need to keep these two applications separate, consider using the virtual host capability with two different host names instead of different ports.

Bill
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another option is to set up two connectors, listening to the same port but on different IP numbers by adding the "address" attribute to the connector elements.
 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your ideas. I tried configuring virtual hosts on Tomcat, but without success. I followed everything on this page. Created a directory named $CATALINA_HOME/conf/Catalina/cab and here is part of my server.xml:


I even put a ROOT.xml in this directory, even though Tomcat 5.5 doesn't have any.(It wasn't working without it as well!)
created a directory $CATALINA_HOME/webapps/cab also and copied a webapp in this directory. But when I give http://10.xxx.xxx.xxx:8080/cab/appname I get


Now what have I done wrong here! Any clues please.
Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you trying to create another host or just another app?

If you just want to create another webapp, you don't need to configure anything.

Simply create a cab directory in webapps and create a WEB-INF directory inside cab and you're done.
 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I am trying to create another host.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I run a number of hosts on a Tomcat instance. In my <Host tags I give a complete path for the appBase where you appear to be trying to use some sort of relative address.

Also note that the name attribute has to be the exact way the host is addressed in URLs - if you want to address http://www.cab.com then www.cab.com should be the name.

Your use of /cab/cabinetroot/resourcemanager is NOT addressing another host but an application to be found under a cab directory in the default host.

Bill
 
Abhishek Asthana
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill

Thanks a ton for your response. After reading your answer I realized what an idiot I was trying to access the application with that URL. I was able to set up virtual host for my tomcat instance.

Thanks a lot.

Just for the sake of completeness of information on this thread:
If you are not using any web server, then you need to manage the host information also. In my case, I added following line to Hosts file on Windows XP. You can see more info here.



Now my URL is: http://cab:<port>/<appname>

Thanks
Abhishek
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic