Java Mailing List Archive

http://www.junlu.com/

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

Accessing Tomcat 4 from Apache 2 with mod_jk2

Sven Bovin

2004-06-09


Hi

First of all: sory for the rather lengthy post, but I think
it is better to provide all info that I think is relevant
at once.

Now for my problem: I'm installing a Web server machine
and I've encountered a rather weird problem: I can access
the "standard" Tomcat examples through Apache (using
mod_jk2), but when I try to access my own web app, it
fails (No Context configured to process this request) when
passing through Apache. If I access it directly (using a
temporary HttpConnector I defined in the server.xml), all
is fine (that is to say: I can access my JSP pages).

I thing I've got an error in my mod_jk2 config. I've tried
Googeling and searching the Tomcat docs and the archives of
this list, but after trying several hints I've found on the
Net, I still can't access my web app :(

The details:

Hardware/Software versions
==========================

- Sun Solaris 5.9 on SPARC (64 bit)
- J2SDK 1.4.1 (pre-installed on the machine)
- Custom compiled Apache 2.0.49 (using GCC 3.3.2)
- GCC 3.3.2
- Custom compiled OpenSSL 0.9.7d (with GCC 3.3.2)
- Tomcat 4.1.30 (binary release)
- Custom compiled mod_jk2 2.0.4 (with GCC 3.3.2)
All custom compiled software *is* 64-bit

Installation and configuration
==============================

I've installed Tomcat 4 and Apache 2. I then compiled
mod_jk2 and OpenSSL 0.9.7d created self-signed SSL
certificates for Apache.

I defined an Alias to the Tomcat example directory in my
Apache httpd.conf configuration file and I load mod_jk2:

----- 8< ----- httpd.conf fragment ----- 8< -----
Alias /examples "/path/to/tomcat/webapps/examples"
<Directory "/path/to/tomcat/webapps/examples">
  Options Indexes Multiviews
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>
<Location "/examples/WEB-INF/">
  AllowOverride None
  Deny from all
</Location>

<IfModule !mod_jk2.c>
  LoadModule jk2_module mod_jk2.so
</IfModule>
----- >8 ----- httpd.conf fragment ----- >8 -----

and I created a workers2.properties:

----- 8< ----- workers2.properties ----- 8< -----
[channel.socket:localhost:8009]
debug=0
port=8009
host=127.0.0.1
tomcatId=localhost:8009

[ajp13:localhost:8009]
channel=channel.socket:localhost:8009

[uri:/examples/*.jsp]
worker=ajp13:localhost:8009
----- >8 ----- workers2.properties ----- >8 -----

I started up Apache and Tomcat (the latter using
/path/to/tomcat/bin/startup.sh). In the browser, I now
have access to https://xxx.xxx.xxx.xxx/examples/ and
everything works fine.

I've then installed my web app under a separate directory
/path/to/application. The web app uses a separate Tomcat
instance and is started with a script like:

----- 8< ----- Tomcat instance startup script ----- 8< -----
export CATALINA_HOME=/path/to/tomcat
export CATALINA_BASE=/path/to/application
export JAVA_HOME=/usr/j2se
export PATH=${PATH}:${JAVA_HOME}/bin/sparcv9
export CLASSPATH=${CATALINA_BASE/webapps/name/jsp/WEB-INF/classes

case "$1" in
  start | reload) $CATALINA_HOME/bin/startup.sh ;;
  stop)       $CATALINA_HOME/bin/shutdown.sh ;;
esac
----- >8 ----- Tomcat instance startup script ----- >8 -----

The current server.xml defines two Connectors: an HttpConnector
for direct acces on port 8180, and the JK2 connector, using port
8109:

----- 8< ----- server.xml fragment ----- 8< -----
<!-- mod_jk2 on port 8109 -->
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
  port="8109" minProcessors="5" maxProcessors="75"
  acceptCount="10" debug="0"
  protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>

<!-- Define an HttpConnector on port 8180 -->
<Connector className="org.apache.catalina.connector.http.HttpConnector"
  port="8180" minProcessors="5" maxProcessors="75"
  enableLookups="true" redirectPort="8443"
  acceptCount="10" debug="0" connectionTimeout="60000"/>
----- >8 ----- server.xml fragment ----- >8 -----

And the context definition is

----- 8< ----- server.xml fragment ----- 8< -----
<Context path="/B2C" docBase="name/jsp" debug="0"
  reloadable="false" crossContext="true">
</Context>
----- >8 ----- server.xml fragment ----- >8 -----

I've defined the following Alias for Apache:

----- 8< ----- httpd.conf fragment ----- 8< -----
Alias /B2C "/path/to/application/webapps/name/jsp"
<Directory "/path/to/application/webapps/name/jsp">
  Options -Indexes
</Directory>
<Location "/B2C/WEB-INF/">
  AllowOverride None
  Deny from all
</Location>
----- >8 ----- httpd.conf fragment ----- >8 -----

and I've added the following lines to the workers2.properties:

----- 8< ----- workers2.properties fragment ----- 8< -----
[channel.socket:localhost:8109]
debug=0
port=8109
host=127.0.0.1
tomcatId=localhost:8109

[ajp13:localhost:8109]
channel=channel.socket:localhost:8109

[uri:/B2C/*.jsp]
worker=ajp13:localhost:8109
----- >8 ----- workers2.properties fragment ----- >8 -----

The /path/to/application/conf/jk2.properties file specifies

----- 8< ----- jk2.properties ----- 8< -----
channelSocket.port=8109
----- >8 ----- jk2.properties ----- >8 -----

When I now start up the Tomcat instance for my application (using
the script defined above) and I restart Apache, I can still access
the Tomcat examples and I can access directly my application (on
HTTP using port 8180). However, if I pass via mod_jk2, I get a
"No context configured" error. What did I do wrong ? I suspect an
error in my mod_jk2 config, since I can access the application
on port 8180.

Note that a similar setup, using mod_jk, *does* work for several
of our projects already !

TIA

Sven

--
Sven Bovin, adjunct Projectleider
Callataÿ & Wouters Financial Software
P. De Dekenstraat 14
B-1040 Brussel

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@(protected)
For additional commands, e-mail: tomcat-user-help@(protected)

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