Meaningless Drivel is fun!*
The moose likes Tomcat and the fly likes Apache-Tomcat Integration Problem: only works locally. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Apache-Tomcat Integration Problem: only works locally." Watch "Apache-Tomcat Integration Problem: only works locally." New topic
Author

Apache-Tomcat Integration Problem: only works locally.

George Yin
Greenhorn

Joined: Dec 13, 2004
Posts: 5
I configured Apache web server and Tomcat to work together. Apache uses port 80; Tomcat uses port 9090. If I use localhost to access the servlet by using http://localhost/myServlet, it works fine. But if I use the domain name like http://www.myDomain.com/myServlet, the servlet does not work. Even if I try on the same local computer. There must be configuration problem. For static pages, http://www.myDomain.com just works fine. By the way I am using a Linsys router, and I have configured the router to enable port 9090.
Thanks for any help.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

How are you getting Apache to forward requests to Tomcat? Are you using mod_jk, Apache conf settings or something else?
George Yin
Greenhorn

Joined: Dec 13, 2004
Posts: 5
Yes, I use mod_jk. I configured it according an internet tutorial. The example servlets works fine.
I tried to add a context node to the Tomcat server.xml file but added it at a wrong place. I deleted the line and restart Tomcat. Now I can not even make the examples to work. I get error similar to "servlet\examples\HelloServletExample not available". Configuring Tomcat is a headache. I am using windows xp.
George Yin
Greenhorn

Joined: Dec 13, 2004
Posts: 5
The example servlets works fine now. I can access them by http://www.myDomain.com/examples/servlet/HelloWorldExample. by still I can not make my servlet work with a domain name
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I'll move this to the Apache/Tomcat forum for you, you'll get a better response there.

Dave
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

Can you send us the relevant portions of your httpd.conf, server.xml and workers.properties files?

What is the error you are getting?
George Yin
Greenhorn

Joined: Dec 13, 2004
Posts: 5
<b>The error message I got is:</b>
HTTP 404 - File not found
Internet Explorer

<b>Portion of the httpd.conf file I added:</b>

Include "C:/Program Files/Apache Group/Tomcat 4.1/conf/auto/mod_jk.conf"
<IfModule !mod_jk.c>
LoadModule jk_module "C:/Program Files/Apache Group/Tomcat 4.1/bin/modules/mod_jk-2.0.42.dll"
</IfModule>

JkWorkersFile "C:/Program Files/Apache Group/Tomcat 4.1/conf/jk/workers.properties"
JkLogFile "C:/Program Files/Apache Group/Tomcat 4.1/logs/mod_jk.log"

JkLogLevel emerg

JkMount /examples ajp13
JkMount /examples/* ajp13

JkMount /webdav ajp13
JkMount /webdav/* ajp13

JkMount /tomcat-docs ajp13
JkMount /tomcat-docs/* ajp13

JkMount /manager ajp13
JkMount /manager/* ajp13

<b>in server.xml, I added this in the <host> node.</b>
<Context path="/praxiswebapp" docBase="praxiswebapp" debug="0" reloadable="true" />

<b>Here is the complete web.xml file which is generated by borland jbuulder</b>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<servlet>
<servlet-name>debugjsp</servlet-name>
<description>Added to compile JSPs with debug info</description>
<servlet-class>org.apache.jasper.servlet.JspServlet</servlet-class>
<init-param>
<param-name>classdebuginfo</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet>
<servlet-name>praxisservlet</servlet-name>
<servlet-class>praxistest.PraxisServlet</servlet-class>
</servlet>
<servlet>
<servlet-name>servlet-shtml</servlet-name>
<servlet-class>com.borland.jbuilder.webserverglue.shtml.ShtmlLoaderEcho</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>debugjsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>servlet-shtml</servlet-name>
<url-pattern>*.shtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>praxisservlet</servlet-name>
<url-pattern>/praxisservlet</url-pattern>
</servlet-mapping>
</web-app>
jay wick
Greenhorn

Joined: Jan 28, 2005
Posts: 4
Hi George.

I don't know if you figured out your problem, but it looks to me that you need a JKMount for the "praxiswebapp".


I would be nice if there were a little map in the Jakarta documentation that said stuff like that.

For instance, I found out the hard way that you may unexpectedly get Apache trying to send requests via AJP12 to a listener on 8007, it seems to be some sort of hard coded fall back feature of mod_jk.
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
I believe that is correct.

You need to add the context path in the httpd.conf.

Either:


This will have to be done for each web application you want handled by Tomcat.
 
wood burning stoves
 
subject: Apache-Tomcat Integration Problem: only works locally.
 
Similar Threads
Virtual host problem
Apache -> Tomcat servlet problem
using tomcat with apache2
servlet URL
Small Tomcat configuration problem