Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Adding a virtual host in Tomcat 5.5

Werner Schalk

2007-01-15

Replies:

Hi,

as I have now spend several hours trying to get this work, I am asking for
your support guys. But please dare with me as I am a complete newbie to
Tomcat.

Basically I installed Tomcat 5.5 and mod_jk 1.2.20 as decribed in
http://gentoo-wiki.com/HOWTO_Apache2_and_Tomcat5 and it works fine (the
samples work fine when I access them via http://localhost/index.jsp and
http://localhost:8080. Now for one of my customers wants to use Tomcat in his
Apache virtual host and run .jsp files. Therefore I added the following lines
to my httpd.conf:

LoadModule jk_module   modules/mod_jk.so
JkWorkersFile  conf/jk-workers.properties
JkLogFile     logs/mod_jk.log
JkLogLevel    info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JkRequestLogFormat "%w %V %T"
jkAutoAlias /var/lib/tomcat-5/default/webapps/
jkMount /*.jsp ajp13

Now, my jk-workers.properties file contains:

worker.list=ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1
worker.ajp13.cachesize=10

Finally here is my server.xml with the new Host section:

<Server port="8010" shutdown="XXXXXXXXXXXXXXX" address="127.0.0.1">

<Service name="Catalina">

  <!-- Define an AJP 1.3 Connector on port 8009 -->
  <Connector port="8009" enableLookups="false" protocol="AJP/1.3"
address="127.0.0.1"/>

  <Engine name="Catalina" defaultHost="localhost">

   <Host name="localhost" appBase="" unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>

   <Host name="myuser" appBase="/home/username/htdocs" unpackWARs="true"
autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
    <Alias>www.mydomain.com</Alias>

    <Valve className="org.apache.catalina.valves.AccessLogValve"
          directory="logs" prefix="myuser_access_log." suffix=".txt"
          pattern="common" resolveHosts="false"/>
   </Host>
  </Engine>
</Service>
</Server>

Then I created the following "hello world" .jsp file in the htdocs directory
of my user (/home/username/htdocs) as defined above:

<HTML>
<HEAD>
<TITLE>Hello World</TITLE>
</HEAD>
<BODY>
<H1>Hello World</H1>
Today is: <%= new java.util.Date().toString() %>
</BODY>
</HTML>

Now the problem is that after restarting both Apache and Tomcat, accessing
this file results in a blank page being displayed by the browser (with no
content whatsoever). But Tomcat is listening on the ports as defined:

# netstat -tunap | grep java
tcp     0    0 127.0.0.1:8009       0.0.0.0:*          LISTEN    
17179/java
tcp     0    0 127.0.0.1:8010       0.0.0.0:*          LISTEN    
17179/java

And even the log is not really helpful:

(Tomcat log)
15.01.2007 17:58:35 org.apache.catalina.core.StandardHost start
INFO: XML validation disabled
15.01.2007 17:58:35 org.apache.catalina.realm.JAASRealm setContainer
INFO: Set JAAS app name Catalina
15.01.2007 17:58:36 org.apache.jk.common.ChannelSocket init
INFO: JK: ajp13 listening on /127.0.0.1:8009
15.01.2007 17:58:36 org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=0/83 config=null
15.01.2007 17:58:36 org.apache.catalina.startup.Catalina start
INFO: Server startup in 1397 ms

Is there anything more I need to do to get this working? What are the mistakes
that I made? I have found so much documentation online about Tomcat, but the
more I read, the more confused I got. So maybe you guys can shed some light
on this...

Thank you very much.

Best regards,
Werner

---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.