aspose file tools*
The moose likes Servlets and the fly likes Servlets, Tomcat, and Apache, oh my! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlets, Tomcat, and Apache, oh my!" Watch "Servlets, Tomcat, and Apache, oh my!" New topic
Author

Servlets, Tomcat, and Apache, oh my!

Anomander Rake
Greenhorn

Joined: May 31, 2005
Posts: 7
I'm having trouble communicating with Tomcat via my browser.

I am using a dedicated server provided by a web host. They installed Apache 2.0, Tomcat 4.somethingorother, (can find out the exact version if anyone needs to know), and J2sdk1,4,2_05. Tomcat is supposedly running under Apache.
The web host uses port 8009 as the default for tomcat.

I turned on Tomcat from the command line and verified that it was listening to port 8009 by listing the open ports. I then restarted Apache. Supposedly, you are supposed to be able to verify that Tomcat is working by using your browser and typing in http://xxx.xxx.xxx.xxx:8009/, (where XXX.XXX.XXX.XXX is my IP address - my domain name is not yet on this server) whereupon you are supposed to get the Tomcat documentation homepage.

Unfortunately, when I use the above url, I get an error messazge saying
"The connection was refused when attempting to contact XXX.XXX.XXX.XXX:8009"

Does anyone know why this might be happening? Might it be some sort of security restriction somewhere? If so where might I look for it? Do I have to use a different URL to access Tomcat when it is running under Apache? A different port?? One source stated that you had to give permission to access Tomcat from a browser in the server.xml file, but that only works when its running as a standalone (and so far I have been unable to find anything telling what I have to type in there to give it permission). Also, what do I do when I want to run a servlet? I tried to access a sample Helloworld servlet in the Tomcat directory but got the same connection refusal error.

As usual the webhost's tech support was of no help at all. Any help would be greatly appreciated.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

8009 should be the port used for communication between Apache and tomcat.
The default port for the standalone connector in Tomcat is 8080.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Anomander Rake
Greenhorn

Joined: May 31, 2005
Posts: 7
Thanks for your reply.

Here's what's in the server.xml file, minus the comments. There are only two references to ports. The first line refers to port 8005, I don't know what its doing. The forth line deals with port 8009. Is it saying that 8009 is for communications with Apache? If so, do I have to put in a similar statement telling Tomcat to use 8080 for browser access to servlets? Or should I be going through Apache somehow??

<Server port="8005" shutdown="SHUTDOWN" debug="0">

<Service name="Tomcat-Apache13">

<Connector className="org.apache.ajp.tomcat4.Ajp13Connector"
port="8009" address="127.0.0.1" minProcessors="5" maxProcessors="75"
enableLookups="true" appBase="webapps"
acceptCount="10" debug="0"/>

<Engine className="org.apache.catalina.connector.warp.WarpEngine"
name="Apache - Tomcat4" defaultHost="defaultHost" debug="0">

<Host name="defaultHost" appbase="/var/www/html">
<Context path="" docBase="" />
</Host>

</Engine>

</Service>
</Server>
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

Did you try accessing it as

http://xxx.xxx.xxx.xxx:8080 ?


The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You're not going to be able to hit the AJP connector directly.
AJP is a pipe between Tomcat and Apache.
If you don't see a connector with port 8080 in the server.xml file, then your hosting company has probably disabled it.

Try hitting a hello world JSP without specifying a port number:
<%="hello, world"%>

Didn't your hosting company provide any documentation?
Anomander Rake
Greenhorn

Joined: May 31, 2005
Posts: 7
http://xxx.xxx.xxx.xxx:8080 doesn't work. Port 8080 is not listed as being listened to when I use "netstat" to get the list. Prior to submitting my first question here, I *did* have to turn Tomcat on, then I restarted Apache (the web host installed it, but just didn't turn it on, apparently). Before I did that, port 8009 was not listed, after I did that, port 8009 is listed as being listened to, presumably Tomcat is now using it to listen for Apache.

Anyway, the server.xml file (see above) does not have anything like a <Connector port="8080" ....> statement. Do I need to type one in, and if so, what is the exact syntax to assign it as the port for communicating with a browser?

As for documentation from the Webhost - almost nonexistent. It's a matter of calling tech support and staying on hold until someone gets around to answering, then you have an approximately 50/50 chance of getting someone who knows what they're talking about. You know the drill. I find forums like this much more helpful - a bit slower, but so far I have plenty of time.

Havn't tried getting the "helloworld" screen directly yet.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Anomander Rake:

Havn't tried getting the "helloworld" screen directly yet.

Yea, try that.
Most of these companies set map "*.jsp" and "/servlet/*" to forward to Tomcat.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlets, Tomcat, and Apache, oh my!