# Setting up mod_jk2 with embedded Tomcat

Note: Replace ${JONAS_BASE} and ${APACHE_HOME} with appropriate values.

1. Backup /$APACHE_HOME/conf/httpd.conf:
cp $APACHE_HOME/conf/httpd.conf $APACHE_HOME/conf/httpd.conf.backup

2. Edit (~line 208) httpd.conf to add the loading of mod_jk2.so:
# Adding jk2_module reference.
LoadModule jk2_module modules/mod_jk2.so

3. Edit $APACHE_HOME/conf.d/JOnAS.conf with the following content:
Alias /docs/jonas "$JONAS_BASE/doc/jonas-4.1.2"
<Directory "$JONAS_BASE/doc/jonas-4.1.2">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
Alias /webapps/jonas "$JONAS_BASE/webapps/jonas"
<Directory "$JONAS_BASE/webapps/jonas">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<IfModule mod_jk2.c>
<Location /earsample>
JkUriSet group jonas
</Location>
<Location /jonasAdmin>
JkUriSet group jonas
</Location>
<Location /cmp2>
JkUriSet group jonas
</Location>
<Location /alarm>
JkUriSet group jonas
</Location>
</IfModule>

4. Edit/create $APACHE_HOME/conf/workers2.properties with the following content:
[logger]
level=DEBUG
# Shared memory handling. Needs to be set.
[shm]
info=Scoreboard. Required for reconfiguration and status with multiprocess servers
file=$APACHE_HOME/logs/jk2.shm
size=1048576
debug=0
disabled=0
# The channel configuration shall be consistent with
# the configuration of JOnAS in server.xml
# port = port of the AJP (jk2) connector
# tomcatId = jvmRoute attribute of the <Engine> element
[channel.socket:toJonas01]
info=channel to a JOnAS instance - tomcatId shall be identical to jvmRoute in the server.xml file of the JOnAS instance
host=localhost
port=9009
group=jonas
[status:status]
info=provides info on the connecteur usage
[uri:$/jkstatus*]
info=get the connector usage info at /jkstatus
group=status:status

5. On the JOnAS side, edit $JONAS_BASE/conf/server.xml with the following content:

...
<Connector className="org.apache.coyote.tomcat5.CoyoteConnector"
port="9009" minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="9043"
acceptCount="10" debug="0" connectionTimeout="0"
useURIValidationHack="false"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"/>
...

<Engine name="Tomcat-JOnAS-Engine" defaultHost="localhost" debug="0" jvmRoute="jonas01">

6. Comment out all lines in $JONAS_BASE/conf/jk2.properties.
7. Restart jonas and httpd services:
service jonas restart; service httpd restart

8. Deploy cmp2.ear and alarm.ear.

9. Those apps are available at:
http://<hostname>/cmp2
http://<hostname>/earsample
http://<hostname>/alarm
http://<hostname>/jonasAdmin