This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Tomcat and the fly likes Internet requests to Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Internet requests to Tomcat" Watch "Internet requests to Tomcat" New topic
Author

Internet requests to Tomcat

David Perry
Greenhorn

Joined: Dec 12, 2003
Posts: 19
I originally posted a similar question regarding this with Windows 2000 Server and I had no success getting it to work. I am now trying with Red Hat 9 and I'm hoping someone can help me out:

I have single server running Red Hat 9 with j2sdk1.4.2_04, httpd-2.0.49 and jakarta-tomcat-4.1.30. Java is working (I compiled a test servlet with no errors); Apache is working (I set up a default web page and I can view it through the browser on the server by typing http://localhost); Tomcat is working (I was able to view my test servlet through the browser on the server by typing http://localhost:8080/mytest/hello).

I have a domain name registered (mysite.com) and have configured the IP address to point to the server. I have had friends test access to the server through the internet by typing www.mysite.com, and they are able to see the default web page. So far so good. What I'm attempting to do now is set up the Tomcat content so that it also can be accessed through the internet (ie. www.mysite.com:8080/mytest/hello). This is where I'm stuck. I don't know how to configure the server/Tomcat to allow internet access to the Tomcat content.

When I set up the server, I entered the hostname as darktower and configured the IP information. I did not configure anything regarding the domain (mysite.com). The following is what my /etc/host file contains:

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 darktower localhost.localdomain localhost

When I start Apache, I get the following message:

httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Can someone please tell me what I have to configure to serve remote requests from the internet to Tomcat? (ie. www.mysite.com:8080/mytest/hello)

Thanking you in advance for any help and feedback. David Perry.

[ June 16, 2004: Message edited by: David Perry ]
[ June 16, 2004: Message edited by: David Perry ]
Jonas Isberg
Ranch Hand

Joined: Mar 18, 2003
Posts: 118
Due to the fact that you, as I understan it, can access both apache (http://localhost) and tomcat (http://localhost:8080) locally and that your friend can access your apache (http://www.mysite.com), it seems that your redhats firewall does not allow incoming traffic on port 8080. It seems that the firewall know that it shall let http traffic (on port 80) pass, both not traffic on port 8080. I am unfortunately lousy on configuring redhats firewall (it is easiest to do when installing I think). One alternative would be to tell tomcat to listen on incoming traffic on port 80 and either shut down apache or tell it to listen on some other port (1024 maybe). Other choises includes trying to set apache up to forward requests to tomcat (it should be far easier to configure the firewall though).

If your only consern is to get a site up with jsp and servlet I would suggest you to install the J2EE Reference Implementation from Sun. It should give you the least headache and most documentation. If you shut down apache and let the J2EE server listen on port 80, you should be ready for some advanced J2EE coding. ;-)
David Perry
Greenhorn

Joined: Dec 12, 2003
Posts: 19
Someone else suggested to me that the firewall might be preventing the requests on port 8080 from getting through. I installed the mod_jk connector and tested access to the Tomcat servlet on the local server by typing http://localhost/myApp/hello and it worked. I then tried accessing the Tomcat servlet from a remote machine through the internet (www.mysite.com/myApp/hello) and it still did not work. Any ideas/suggestions as to why this is not working?

As for the suggestion to use the J2EE Reference Implementation from Sun; is this a better/more widely used alternative to Tomcat? Is Tomcat typically only used in a development environment? I ask this because in all of my searching for information on how set up Tomcat to handle remote requests from the internet (www.mysite.com/myApp/hello) I have only found information on configuring it to work locally (http://localhost:8080/myApp/hello).

Thank you for your comments. David.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

1) you had no success with windows ( http://www.coderanch.com/t/83869/Tomcat/Request-Tomcat-remote-machine ) so now you're trying an operating system that is known to be "less user friendly". I don't mean to start a flame war between windows/nix, but c'mon.

2) There is fundamentally no difference between the *how* of configuring Apache, Tomcat or Apache/Tomcat through localhost or through a domain name. If you follow the directions you've been pointed to for localhost, then that's how to configure what's on your box. You've already figured out how to get the domain pointed at your box (because you can access apache content remotely). So the trouble is not in the difference between localhost and remote access. It probably has to do with how you've configured JK. This is known to be a tricky thing for many.

3) Tomcat is used in production sites that support millions of hits a day. The J2EE reference implementation, on the other hand, is not. And was never meant to be. And by the way, servlet/jsp programming is very much a different pursuit from "some advanced J2EE coding". It's inappropriate to even suggest you need a full-blown J2EE container. If you're not writing EJBs, then stick with Tomcat.

4) 8080 through the firewall??? Where in this url do you see 8080?
http://www.mysite.com/myApp/hello
Avoiding having to configure your firewall to allow traffic on 8080 is the *entire* point of configuring Apache to connect to Tomcat. Perhaps that was in reference to what you had tried in the very first post (testing tomcat stand-alone). Then in fact, your firewall is probalby the problem. But once you're accessing tomcat through apache, 8080 and your firewall means nothing.


5) Redhat has its own particular flavour of Apache installed. It has been known to behave *slightly differently*, and so certain instructions you'll find that are not *specifically* rh instructions, may not work. In fact, the one remaining RH box we have at work, has had it's RH-apache turned off, and we installed and configured a separate instance of Apache. All our other boxes are Slackware.

6) At this point, are you willing to try Tomcat stand-alone? From my own experience, it seems easier to get Tomcat working, and then add apache in front, after the fact.
David Perry
Greenhorn

Joined: Dec 12, 2003
Posts: 19
1) you had no success with windows ( http://www.coderanch.com/t/83869/Tomcat/Request-Tomcat-remote-machine ) so now you're trying an operating system that is known to be "less user friendly". I don't mean to start a flame war between windows/nix, but c'mon.

>> I wasn't trying to imply that I thought it would be easier on Linux than Windows, but rather that I thought I'd have more success getting some help.

2) So the trouble is not in the difference between localhost and remote access. It probably has to do with how you've configured JK. This is known to be a tricky thing for many.

>> As it stands now, yes, that is my problem; I can get access to the Apache content from an internet connection (www.mysite.com) and I can access the Tomcat content locally through the mod_jk connector (http://localhost/myApp/hello). I'm dead in the water with the next step; accessing Tomcat through Apache using the mod_jk connector (www.mysite.com/myApp/hello). I'm looking for some help/feedback regarding issues with the mod_jk configuration.

3) It's inappropriate to even suggest you need a full-blown J2EE container. If you're not writing EJBs, then stick with Tomcat.

>> I asked this question because J2EE was suggested. As I mentioned, I only just learned this stuff in school (programming side) and, based on the lack of information out there regarding configuration of internet access to Tomcat content, my thinking was that Tomcat might be used primarily as a development tool, and therefore I wanted some clarification. Your answer clarified that and I appreciate your feedback.

4) 8080 through the firewall??? Where in this url do you see 8080?
http://www.mysite.com/myApp/hello...Perhaps that was in reference to what you had tried in the very first post (testing tomcat stand-alone).

>> Yes, you're right. Originally, I just tried gaining access to the Tomcat content directly. However, after trying and not having any success, I installed the mod_jk connector. As I mentioned above, this is where I'm at now, however I can't get the internet access to work (www.mysite.com/myApp/hello). This is where I need some help/suggestions.

5) Redhat has its own particular flavour of Apache installed....

>> When I installed Linux, I did not install any of the web server components. I downloaded Apache from their site and installed.

6) At this point, are you willing to try Tomcat stand-alone? From my own experience, it seems easier to get Tomcat working, and then add apache in front, after the fact.

>> I tried that. I installed Linux, then installed, configured and tested Tomcat. I got it working on http://localhost:8080/myApp/hello but was unable to get the internet access to work (www.mysite.com/myApp/hello). At that point, I installed Apache, tested it to make sure I could access the machine remotely (www.mysite.com). When this worked, I realized that my problem is with configuring the remote access to Tomcat. It was at this point, I installed the mod_jk connector and that brings me to where I am today.
>>>
I guess I'm guilty of not articulating my situation clearly. If I've offended/frustrated anyone by my choice of wording or the way I've described my situation, I'm sorry; it was not intentional.
Once again, if anyone can help me out, I'd appreciate it greatly. Thank you. David.
Jeff Madrid
Greenhorn

Joined: Nov 07, 2003
Posts: 14
David,

I'd check out these two resources. I had some of the same pain you've been experiencing and together these documents got me through it. In particular, read section 4.2 of the second link. I think it may have the answer you are looking for.


http://www.johnturner.com/howto/apache2-tomcat4127-jk-rh9-howto.html

http://www.meritonlinesystems.com/docs/apache_tomcat_redhat.html

Good luck,

Jeff
[ June 21, 2004: Message edited by: Jeff Madrid ]

Jeff
David Perry
Greenhorn

Joined: Dec 12, 2003
Posts: 19
Thanks for your feedback. I have referenced both of the documents you suggested, however, between the two of them, I haven't been able to figure out what I'm doing wrong.

If you've been able to configure your server to allow remote machines access your Tomcat content, would you mind emailing me (davidp@cogeco.ca) your configuration files (httpd.conf, server.xml, workers.properties, /etc/hosts) so that I check your settings for clues as to what I'm doing wrong?

P.S.-Anyone out there that has been able to achieve this, please feel free to email me the above requested files.

Thanks. David.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Internet requests to Tomcat