You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Matthew Strawbridge <ma...@philoxenic.com> on 2005/07/11 15:54:57 UTC

Trying to configure apache, tomcat and mod_jk

Hi

After spending several days trying to set this up from the 
documentation, I've finally decided I need some expert help.

I have a server set up with several domains sharing an IP address. I 
want to be able to have JSP files in amongst my static files, and 
have apache serve the static ones and to forward the requests for 
*.jsp to tomcat using mod_jk.

At present:
http://www.philoxenic.com:8080/test.jsp correctly serves up 
/home/httpd/vhosts/philoxenic.com/jsp/test.jsp through tomcat. (I 
would rather have these files in ../httpdocs/, but thought it might 
be easier if apache couldn't find the files itself).

http://www.philoxenic.com/test.jsp comes up with a 'Not Found' error. 
This is what I want to get working.

If I copy test.jsp from 'jsp' to 'httpdocs' then 
http://www.philoxenic.com/test.jsp serves it up as plain HTML (i.e. 
bypassing Tomcat).

Please can someone point me in the right direction. To get this far 
I've had to recompile apache, compile tomcat and mod_jk, and think I 
have been going round in circles following out-of-date documents on 
the Web. I feel I'm close, but perhaps can't see the wood for the 
trees.

Thanks
Matthew


VERSIONS:
Red Hat Linux 9
Apache 2.0.40
Tomcat 5.5.9
jakarta-tomcat-connectors-1.2.13

FILES:
/usr/local/jakarta-tomcat-5/conf/server.xml:

<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
  <GlobalNamingResources>

    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
       description="User database that can be updated and saved"
           factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
          pathname="conf/tomcat-users.xml" />

  </GlobalNamingResources>
  <Service name="Catalina">
    <Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
               port="8009" minProcessors="5" maxProcessors="75"
               enableLookups="true" acceptCount="10" debug="0"
               connectionTimeout="20000" useURIValidationHack="false"
               protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />
    <Engine name="Catalina" defaultHost="localhost">
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>
      <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">
      </Host>

      <Host name="www.philoxenic.com">
        <Context path="" docBase="/home/httpd/vhosts/philoxenic.com/jsp" debug="1" reloadable="true"/>
      </Host>

    </Engine>

  </Service>

</Server>


/usr/local/apache2/conf/httpd.conf:
[SNIP]
  LoadModule    jk_module  /usr/local/apache2/modules/mod_jk.so
  JkWorkersFile /usr/local/apache2/conf/workers.properties
  JkLogFile     /var/log/httpd/mod_jk.log
  JkLogLevel    debug
  JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
  JkOptions     +ForwardKeySize +ForwardURICompat -ForwardDirectories
  JkRequestLogFormat     "%w %V %T"
  JkMount  /*.jsp ajp13
  JkMount  /examples/* ajp13


/usr/local/apache2/conf/workers.properties:
workers.tomcat_home=/usr/local/jakarta-tomcat-5
workers.java_home=/usr/java/jdk1.5.0_04
ps=/
worker.list=ajp12, ajp13
worker.ajp12.port=8007
worker.ajp12.host=localhost
worker.ajp12.type=ajp12
worker.ajp12.lbfactor=1
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp13.type=ajp13
worker.ajp13.lbfactor=1
worker.loadbalancer.type=lb
worker.loadbalancer.balanced_workers=ajp12, ajp13
worker.inprocess.type=jni
worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)tomcat.jar
worker.inprocess.cmd_line=start
worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)lib$(ps)i386$(ps)server$(ps)libjvm.so
worker.inprocess.stdout=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stdout
worker.inprocess.stderr=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stderr


LOGS:

/var/log/httpd/mod_jk.log:
[Mon Jul 11 06:26:32 2005] [10660:16384] [debug] map_uri_to_worker::jk_uri_worker_map.c (442): Attempting to map URI '/test.jsp' from 1 maps
[Mon Jul 11 06:26:32 2005] [10660:16384] [debug] map_uri_to_worker::jk_uri_worker_map.c (454): Attempting to map context URI '/home/httpd/vhosts/philoxenic.com/httpdocs/*.jsp'
[Mon Jul 11 06:26:32 2005] [10660:16384] [debug] map_uri_to_worker::jk_uri_worker_map.c (442): Attempting to map URI '/test.jsp' from 1 maps
[Mon Jul 11 06:26:32 2005] [10660:16384] [debug] map_uri_to_worker::jk_uri_worker_map.c (454): Attempting to map context URI '/home/httpd/vhosts/philoxenic.com/httpdocs/*.jsp'
[Mon Jul 11 06:26:32 2005] [10660:16384] [debug] map_uri_to_worker::jk_uri_worker_map.c (442): Attempting to map URI '/error_docs/not_found.html' from 1 maps
[Mon Jul 11 06:26:32 2005] [10660:16384] [debug] map_uri_to_worker::jk_uri_worker_map.c (454): Attempting to map context URI '/home/httpd/vhosts/philoxenic.com/httpdocs/*.jsp'

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Trying to configure apache, tomcat and mod_jk

Posted by Alan Chandler <al...@chandlerfamily.org.uk>.
On Monday 11 July 2005 14:54, Matthew Strawbridge wrote:
> Hi
>
> After spending several days trying to set this up from the
> documentation, I've finally decided I need some expert help.

I am no expert, but I got it to work 

See my blog on

http://home.chandlerfamily.org.uk/archive/21/taking-the-java-plunge---setting-up-apache-and-tomcat

Just a quick look at your server.xml file seems to be missing the 

<engine jvmroute= ...

that I have.

-- 
Alan Chandler
http://www.chandlerfamily.org.uk

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Trying to configure apache, tomcat and mod_jk

Posted by Paul George Constantine <pa...@stanford.edu>.
Hey Matthew,

I'm no expert, but I can tell you what I did to get it running. I'm  running
Apache 2.0 on Fedora Core 4. I basically ended up just rolling back my
versions to get things to work. I rolled back to Tomcat 5.0.28 with mod_jk
1.2.10.

It's true. The documentation on the web is out of date and very confusing.

I set things up considerably different, though. For example, I was just
trying to serve jsp's from the $CATALINA_HOME\webapps directory. I'm not
entirely sure, but I think the JkMount directive only points to that
directory.

It looks like you're defining more workers in your workers.properties than
you're actually using in httpd.conf. I don't think you need the ajp12
worker.

Another thing is that you have not defined a JkShmFile (a shared memory
file). This is required for connectors 1.2.10 and later (although 1.2.13
might set one up on its own).

Here's a link to the relevant lines in my config files. I got this working
this weekend, so you can be sure they're fresh.

http://ill-conditioned.stanford.edu/JSPWiki/Wiki.jsp?page=Fedora

If the wiki link doesn't work, then you know I'm still having problems. :)

Hope this helps,
Paul

Quoting Matthew Strawbridge <ma...@philoxenic.com>:

> Hi
>
> After spending several days trying to set this up from the
> documentation, I've finally decided I need some expert help.
>
> I have a server set up with several domains sharing an IP address. I
> want to be able to have JSP files in amongst my static files, and
> have apache serve the static ones and to forward the requests for
> *.jsp to tomcat using mod_jk.
>
> At present:
> http://www.philoxenic.com:8080/test.jsp correctly serves up
> /home/httpd/vhosts/philoxenic.com/jsp/test.jsp through tomcat. (I
> would rather have these files in ../httpdocs/, but thought it might
> be easier if apache couldn't find the files itself).
>
> http://www.philoxenic.com/test.jsp comes up with a 'Not Found' error.
> This is what I want to get working.
>
> If I copy test.jsp from 'jsp' to 'httpdocs' then
> http://www.philoxenic.com/test.jsp serves it up as plain HTML (i.e.
> bypassing Tomcat).
>
> Please can someone point me in the right direction. To get this far
> I've had to recompile apache, compile tomcat and mod_jk, and think I
> have been going round in circles following out-of-date documents on
> the Web. I feel I'm close, but perhaps can't see the wood for the
> trees.
>
> Thanks
> Matthew
>
>
> VERSIONS:
> Red Hat Linux 9
> Apache 2.0.40
> Tomcat 5.5.9
> jakarta-tomcat-connectors-1.2.13
>
> FILES:
> /usr/local/jakarta-tomcat-5/conf/server.xml:
>
> <Server port="8005" shutdown="SHUTDOWN">
>   <Listener
> className="org.apache.catalina.mbeans.ServerLifecycleListener" />
>   <Listener
> className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
> />
>   <Listener
> className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>
>   <GlobalNamingResources>
>
>     <!-- Test entry for demonstration purposes -->
>     <Environment name="simpleValue" type="java.lang.Integer" value="30"/>
>
>     <!-- Editable user database that can also be used by
>          UserDatabaseRealm to authenticate users -->
>     <Resource name="UserDatabase" auth="Container"
>               type="org.apache.catalina.UserDatabase"
>        description="User database that can be updated and saved"
>            factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
>           pathname="conf/tomcat-users.xml" />
>
>   </GlobalNamingResources>
>   <Service name="Catalina">
>     <Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
>                port="8009" minProcessors="5" maxProcessors="75"
>                enableLookups="true" acceptCount="10" debug="0"
>                connectionTimeout="20000" useURIValidationHack="false"
>
> protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
>
>     <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
>     <Connector port="8080" maxHttpHeaderSize="8192"
>                maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
>                enableLookups="false" redirectPort="8443"
> acceptCount="100"
>                connectionTimeout="20000" disableUploadTimeout="true" />
>     <Engine name="Catalina" defaultHost="localhost">
>       <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
>              resourceName="UserDatabase"/>
>       <Host name="localhost" appBase="webapps"
>        unpackWARs="true" autoDeploy="true"
>        xmlValidation="false" xmlNamespaceAware="false">
>       </Host>
>
>       <Host name="www.philoxenic.com">
>         <Context path="" docBase="/home/httpd/vhosts/philoxenic.com/jsp"
> debug="1" reloadable="true"/>
>       </Host>
>
>     </Engine>
>
>   </Service>
>
> </Server>
>
>
> /usr/local/apache2/conf/httpd.conf:
> [SNIP]
>   LoadModule    jk_module  /usr/local/apache2/modules/mod_jk.so
>   JkWorkersFile /usr/local/apache2/conf/workers.properties
>   JkLogFile     /var/log/httpd/mod_jk.log
>   JkLogLevel    debug
>   JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
>   JkOptions     +ForwardKeySize +ForwardURICompat -ForwardDirectories
>   JkRequestLogFormat     "%w %V %T"
>   JkMount  /*.jsp ajp13
>   JkMount  /examples/* ajp13
>
>
> /usr/local/apache2/conf/workers.properties:
> workers.tomcat_home=/usr/local/jakarta-tomcat-5
> workers.java_home=/usr/java/jdk1.5.0_04
> ps=/
> worker.list=ajp12, ajp13
> worker.ajp12.port=8007
> worker.ajp12.host=localhost
> worker.ajp12.type=ajp12
> worker.ajp12.lbfactor=1
> worker.ajp13.port=8009
> worker.ajp13.host=localhost
> worker.ajp13.type=ajp13
> worker.ajp13.lbfactor=1
> worker.loadbalancer.type=lb
> worker.loadbalancer.balanced_workers=ajp12, ajp13
> worker.inprocess.type=jni
> worker.inprocess.class_path=$(workers.tomcat_home)$(ps)lib$(ps)tomcat.jar
> worker.inprocess.cmd_line=start
>
worker.inprocess.jvm_lib=$(workers.java_home)$(ps)jre$(ps)lib$(ps)i386$(ps)server$(ps)libjvm.so
>
worker.inprocess.stdout=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stdout
>
worker.inprocess.stderr=$(workers.tomcat_home)$(ps)logs$(ps)inprocess.stderr
>
>
> LOGS:
>
> /var/log/httpd/mod_jk.log:
> [Mon Jul 11 06:26:32 2005] [10660:16384] [debug]
> map_uri_to_worker::jk_uri_worker_map.c (442): Attempting to map URI
> '/test.jsp' from 1 maps
> [Mon Jul 11 06:26:32 2005] [10660:16384] [debug]
> map_uri_to_worker::jk_uri_worker_map.c (454): Attempting to map context
> URI '/home/httpd/vhosts/philoxenic.com/httpdocs/*.jsp'
> [Mon Jul 11 06:26:32 2005] [10660:16384] [debug]
> map_uri_to_worker::jk_uri_worker_map.c (442): Attempting to map URI
> '/test.jsp' from 1 maps
> [Mon Jul 11 06:26:32 2005] [10660:16384] [debug]
> map_uri_to_worker::jk_uri_worker_map.c (454): Attempting to map context
> URI '/home/httpd/vhosts/philoxenic.com/httpdocs/*.jsp'
> [Mon Jul 11 06:26:32 2005] [10660:16384] [debug]
> map_uri_to_worker::jk_uri_worker_map.c (442): Attempting to map URI
> '/error_docs/not_found.html' from 1 maps
> [Mon Jul 11 06:26:32 2005] [10660:16384] [debug]
> map_uri_to_worker::jk_uri_worker_map.c (454): Attempting to map context
> URI '/home/httpd/vhosts/philoxenic.com/httpdocs/*.jsp'
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org