0
votes

I am trying integrate apache2.2 and tomcat7 by mod_jk. I have found some examples on web and trying to figure it out. But still not clear for me. Following is my config

Apache config

/etc/apache2/mods-available/jk.conf:

<IfModule jk_module>
JkWorkersFile /etc/libapache2-mod-jk/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
...

/etc/apache2/mods-available/jk.load:

LoadModule jk_module /usr/lib/apache2/modules/mod_jk.so

/etc/libapache2-mod-jk/workers.properties:

workers.tomcat_home=/usr/share/tomcat7
workers.java_home=/usr/lib/jvm/java-1.7.0-openjdk-i386
ps=/
worker.list=ajp13_worker

worker.ajp13_worker.port=8009
worker.ajp13_worker.host=localhost
worker.ajp13_worker.type=ajp13

worker.ajp13_worker.lbfactor=1

worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=ajp13_worker

Tomcat config

/etc/tomcat6/server.xml:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Following is my testing

Work case

/etc/apache2/sites-available/000-default:

...
JkMount /examples/*/*.jsp ajp13_worker
JkMount /examples/*/servlet/* ajp13_worker
Alias /examples "/usr/share/tomcat7-examples/examples"
<Directory "/usr/share/tomcat7-examples/examples">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        allow from all
</Directory>

Fail case

After modify /etc/apache2/sites-available/000-default to following

...
JkMount /examples3/*/*.jsp ajp13_worker
JkMount /examples3/*/servlet/* ajp13_worker
Alias /examples3 "/usr/share/tomcat7-examples/examples"
<Directory "/usr/share/tomcat7-examples/examples">
        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        allow from all
</Directory>

it will get 404 error when I trying http://www.test.com/examples3/jsp/jsp2/el/basic-arithmetic.jsp

Why is that?

1

1 Answers

0
votes

I found out the root cause. It is the permission issue for creating compiled jsp class file in /var/lib/tomcat7/work/Catalina/localhost/examples3/. Somehow I have created examples3 in /var/lib/tomcat7/work/Catalina/localhost/ with root. That's why the user tomcat7 cannot create class object which compiled from jsp this folder. After removing examples3 it works fine now.

drwxr-xr-x 3 tomcat7 tomcat7 4096 Jun 4 17:18 examples

drwxr-xr-x 2 root root 4096 Jun 4 17:37 examples3