tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Turner <tomcat-u...@johnturner.com>
Subject Re: 2 VirtualHosts same IP address and port on Tomcat not working
Date Fri, 22 Aug 2003 12:29:04 GMT

Advice:

Forget about servlets.  Forget about serving all content from a servlet. 
  Too many variables, causing you too much confusion.

Take it one step at a time.

First:  set up Tomcat so that you have 2 virtual hosts.  Each virtual 
host needs a SEPARATE appBase.  If BOTH virtual hosts are to be 
IDENTICAL, then DON'T use a separate Host node for the second one (or a 
separate appBase), instead set up one Host node and use the <Alias> 
directive in server.xml to alias the second hostname to the first.

Second: Create your Contexts.  Root, subdir, whatever, set it up as you 
plan to use them in your URLs.

Third: Create a SIMPLE JSP, like "hello world" or whatever.  Put that in 
the appropriate Context.  Stop Tomcat.  Delete EVERYTHING in the work 
directory (but not the work directory itself).  Start Tomcat.

Fourth:  Verify that http://host1:8080/yourContext1/yourSimple.jsp works 
as expected.

Fifth: Verify that http://host2:8080/yourContext2/yourSimple.jsp works 
as expected.

Then, and only then, worry about Apache.  If you get to this step, then 
you know Tomcat is OK and your problems are Apache related.  Right now 
you are fudging with both ends of the equation, and being wrong in 
either or both can make the whole thing fall apart with zero indication 
of which end is causing the problem.

Sixth: create a VirtualHost in httpd.conf.  Set the DocumentRoot to be 
equal to the Context in server.xml.  Thus, everything you do from that 
point on in your app has to be relative to the webapp root and URLs for 
static and dynamic content will be the same.

Seventh: Setup your JkMount.  If your DocumentRoot is set correctly, and 
your Contexts are set correctly, you should be able to get what you want 
with:

JkMount /*.jsp ajp13
JkMount /servlet/* ajp13

assuming your servlets are in /servlet.  You might also want to consider 
putting an extension on your servlets, as in Struts, like *.do or 
something.  This makes JkMount even easier.

This is only for testing.  Once you have it working, and you want to 
generate everything with a servlet, then change your JkMount to /*.

John

David Wynter wrote:

> Hi,
> 
> I have read dozens of archived posts on virtualhost. I have distilled my
> httpd.conf and server.xml back to what seems to be the recommended approach,
> see below. But now I can see no sites on any URL. I have a suspicous "End
> event threw exception" in the catalina.out log, which suggests a problem
> with server.xml, but reading it I cannot see any illegal XML, so assume it
> is a configuration value error. At the end of the exception it also has
> "...IllegalArguementException: Servlet mapping specifies an unknown servlet
> name rwsite" which suggests it doesn't like my second Host configuration.
> But I copied and pasted it from a posted version that worked and just
> changed the appBase and servername to appropriate values?
> 
> In my error_log I get 2 types of errors:
> 1.  "Directory Index forbidden by rule:
> /usr/local/jakarta-tomcat-4.1.12/webapp1/rwsite" - there is that same
> troublesome rwsite again.
> 2. "File does not exist:
> /usr/local/jakarta-tomcat-4.1.12/webapp1/rwsite/servlet" it's not a file but
> a directory? and I get "File does not exist:
> /usr/local/jakarta-tomcat-4.1.12/webapp2/se/servlet, referer:
> http://www.stpenable.com/se/servlet/se/template/solutions%2Cmdmanage.vm"
> which is real.
> 



Mime
View raw message