# [SOLVED] mod_jk -> Apache/Apache2 connector for Tomcat

## cybermatthieu

Hi!

I've been trying to install this for a while now... Is there anyone who was able to install the mod_jk on apache 2??? I found some post on this but when I followed there step I ended up with this error :

```
Cannot load /usr/lib/apache2/modules/mod_jk.so into server: /usr/lib/apache2/modules/mod_jk.so: undefined symbol: ap_null_cleanup
```

I find this topic to be very bad documented...  :Sad: 

Any help will be appreciated,

MattLast edited by cybermatthieu on Thu Sep 15, 2005 4:22 pm; edited 1 time in total

----------

## eealex

Yes I did this by a all portage approach for all Apache2, Tomcat5, jk (not jk2).

```
eealex ~ # emerge -p apache tomcat mod_jk

These are the packages that I would merge, in order:

Calculating dependencies ...done!

[ebuild   R   ] net-www/apache-2.0.54-r14

[ebuild   R   ] www-servers/tomcat-5.0.27-r6

[ebuild   R   ] www-apache/mod_jk-1.2.13

```

But the organizaton of config files for Apache2 has changed since some version (I guess from 2.0.53 or 54?).  I have /etc/apache2/modules.d/88_mod_jk.conf which do the main job for connecting Apache2 and Tomcat.  Well I remember what I have done is basically add a 

```
jkMount /app/* ajp13
```

to that file...

----------

## cybermatthieu

Is it normal that when ever I try to emerge  mod_jk It tries to intall apache 1.3 even if I have apache2 already installed?

```

#emerge -p apache tomcat mod_jk

[ebuild   R   ] net-www/apache-2.0.54-r9

[ebuild   R   ] www-servers/tomcat-5.0.27-r6

[ebuild  N    ] dev-libs/mm-1.2.1

[ebuild  NS   ] net-www/apache-1.3.33-r5

[ebuild  N    ] www-apache/mod_jk-1.2.13

[ebuild  N    ] net-www/mod_ssl-2.8.22

```

Thanks for the rely!  :Smile: 

----------

## eealex

 *cybermatthieu wrote:*   

> Is it normal that when ever I try to emerge  mod_jk It tries to intall apache 1.3 even if I have apache2 already installed?
> 
> ```
> 
> #emerge -p apache tomcat mod_jk
> ...

 

You can add apache2 to your use flag for mod_jk so that it emerges Apache2.   Also as I remember it actually requires >=apache-2.0.54-r10, and in turn apache-2.0.54-r10 requires apr, apr-util, gentoo-webroot-default and they are all masked at this moment... Seems that you already have an Apache server up and running.  So just backup all your config files probably or otherwise your will have a hard time as they put the config file in the new location and new organization (well actually a simlink from /usr/lib/apache2/conf to /etc/apache2 but now everything is based on /usr/lib/apache2 and you need to make appropriate change).

For your reference, my /etc/portage/package.keywords file (the related parts):

```
www-apache/mod_jk ~x86

>=net-www/apache-2.0.54-r10

=net-www/gentoo-webroot-default-0.2 ~x86

=dev-libs/apr-0.9.6 ~x86

=dev-libs/apr-util-0.9.6 ~x86

```

EDITED: Probably you will also want to look at this to make your modules work:

http://www.gentoo.org/doc/en/apache-troubleshooting.xml#doc_chap2

----------

## cybermatthieu

I managed to add the apache2 to my use flag and now when I emerge mod_jk It doesn't tries to install apache1.x!

So one step foward, but now I'm still not running *.jsp anywhere in my /var/www/localhost/htdocs. So if you would post your config it whould really help me out.

Thanks,

Matt

----------

## eealex

 *cybermatthieu wrote:*   

> I managed to add the apache2 to my use flag and now when I emerge mod_jk It doesn't tries to install apache1.x!
> 
> So one step foward, but now I'm still not running *.jsp anywhere in my /var/www/localhost/htdocs. So if you would post your config it whould really help me out.
> 
> Thanks,
> ...

 

Someone please correct me if my concept is wrong... 

The idea of JK is when apache see some rules match in JK configuration it will internally transfer the request to Tomcat and Tomcat will handle it.  So finally the configuration will bind to that of Tomcat (probably /opt/tomcat/conf if you use portage?)

I haven't tried your configuration but your JSP should be put in the root directory of tomcat (like /opt/tomcat/webapps/ROOT).  surely this ROOT is defined by Tomcat configuration file and you may try changing this to your apache htdocs...  though not quite recommend. 

For your information I added something to my /etc/apache2/modules.d/88_mod_jk.conf 

```

<IfDefine JK>

LoadModule jk_module    modules/mod_jk.so

JkWorkersFile   conf/jk-workers.properties

JkLogFile       logs/mod_jk.log

JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories

JkRequestLogFormat "%w %V %T"

jkAutoAlias /var/lib/tomcat-5/default/webapps/

jkMount /*.jsp ajp13

jkMount /pebble/* ajp13

</IfDefine>

```

Such that when request to http://mysite/pebble/ then it will go to the pebble webapps

I remember it when request to say http://mysite/index.jsp it should go to Tomcat webapps/ROOT/index.jsp (but mine is down now due to a recent emerge of apache... still troubleshooting   :Confused:  )

EDITED: Fixed the issue by emerge mod_jk again..  verified that request to http://mysite/index.htm will go to htdocs while http://mysite/index.jsp will go to webapps/ROOT/index.jsp .   For your information my current apache, tomcat, mod_jk, and use flags if helpful::

```
eealex modules.d # emerge -pv apache tomcat mod_jk

These are the packages that I would merge, in order:

Calculating dependencies ...done!

[ebuild   R   ] net-www/apache-2.0.54-r30  -apache2 -debug -doc -ldap -mpm-leader -mpm-peruser -mpm-prefork -mpm-threadpool -mpm-worker -no-suexec (-selinux) +ssl -static-modules -threads 0 kB

[ebuild   R   ] www-servers/tomcat-5.0.27-r6  -doc -jikes 0 kB

[ebuild   R   ] www-apache/mod_jk-1.2.13  +apache2 0 kB

Total size of downloads: 0 kB

```

Last edited by eealex on Thu Sep 15, 2005 1:38 am; edited 1 time in total

----------

## cybermatthieu

Hi again,

Thanks for all youre help! I'm starting to get the purpose of the connector... It's kinda working, I can access the index.jsp (the defaults pages that comes with tomcat5) but there's no picture loading and if I try to click on any link in the menu (ex: JSP exemples) I get a file not found error.

I know I'm close to fix it but I juste can't figure it out...

So thanks again for youre help,

Matt

----------

## cybermatthieu

I managed to find a it!

In modules.d/88_mod_jk.conf I had :

```
jkMount /*.jps ajp13
```

And I replace it by :

```
jkMount /* ajp13
```

Now it's all working! I know it's only a temporary solution because now I foward everything to tomcat so my apache document doesn't show...

Thanks again for all your help,

MattLast edited by cybermatthieu on Thu Sep 15, 2005 5:17 am; edited 1 time in total

----------

## eealex

You are welcome..  but if you just jkMount /*, so what is the purpose of Apache?

----------

## cybermatthieu

Exactly!  :Smile: 

I'm still playing around with the configuration but now at last now It's a bit more functionnal.

Thanks,

Matt

----------

## p4m

 *cybermatthieu wrote:*   

> 
> 
> In modules.d/88_mod_jk.conf I had :
> 
> ```
> ...

 

Perhaps it doesn't work due to a typo: 

```
jkMount /*.jsp ajp13
```

----------

## opensas

Can anybody tell me what shuld I do to set up tomcat 5.0.27-r6, with mod_jk 1.2.13 but with apache 2.0.54-r31

I followed this guide but when I go to http://localhost/index.jsp I get the following error

```

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Apache Server at localhost Port 80

```

If I access thru localhost:8080 verything works fine, so I guess the problem is not Tomcat but the mod_jk connector.

this is my conf file

```

tux ~ # cat /etc/conf.d/apache2 | grep APACHE2_OPTS

# and other features of apache using the APACHE2_OPTS line. Every module should

APACHE2_OPTS="-D DEFAULT_VHOST -D JK -D PHP5"

```

this is what I get in the log file

```

tux apache2 # cat mod_jk.log

[Fri Nov 18 04:27:26 2005] [8836:52064] [debug] map_uri_to_worker::jk_uri_worker_map.c (442): Attempting to map URI '/index.jsp' from 1 maps

[Fri Nov 18 04:27:26 2005] [8836:52064] [debug] map_uri_to_worker::jk_uri_worker_map.c (454): Attempting to map context URI '/*.jsp'

[Fri Nov 18 04:27:26 2005] [8836:52064] [debug] map_uri_to_worker::jk_uri_worker_map.c (468): Found a wildchar match ajp13 -> /*.jsp

[Fri Nov 18 04:27:26 2005] [8836:52064] [debug] jk_handler::mod_jk.c (1814): Into handler jakarta-servlet worker=ajp13 r->proxyreq=0

[Fri Nov 18 04:27:26 2005] [8836:52064] [debug] wc_get_worker_for_name::jk_worker.c (111): did not find a worker ajp13

[Fri Nov 18 04:27:26 2005] [8836:52064] [info]  jk_handler::mod_jk.c (1985): Could not find a worker for worker name=ajp13

```

Saludos

Sas

----------

## roostero

Hi guys,

I've been reading this thread at it explains my problem pretty well. What I want is static html and php pages to be served by Apache and and jsp/servlets by tomcat.

I have configured both servers so that they work independentlly and configured mod_jk however I have the following problem:

http://localhost/index.jsp

Shows no images and also Tomcat Manager and Tomcat Administrator links dont work. I understand why this is happening to a degree as my

```
88_mod_jk_conf
```

Only has the rule

```
jkMount /*.jsp ajp13
```

And neither the tomcat images or /Manager comply to this rule.

However my question is, how do I actually get them to work? do I need to add some specific config to Apache????

Many thanks in advance,

----------

## piggie

roostero: the reason your images arent showing up is because of the line:

```

jkMount /*.jsp ajp13

```

The jkMount setting merely tells apache what to send to tomcat.

So if you had a webapp called TestApp inside tomcat, you could use this instead:

```

jkMount /*.jsp ajp13

jkMount /TestApp/* ajp13

```

You could then go to http://yourapachemachine.yourdomain.com/TestApp/ and it should serve up as normal.

I spent a while on this myself, and then it hit me like a large hammer.

----------

## roostero

Thanks a lot piggie, your suggestion worked like a charm   :Razz: 

Your right about the hammer too!!

----------

## dcmau

Same problem here to.

So do we have to manually add each directory to '88_mod_jk.conf' or is there some other way to forward any unfound files from apache to Tomcat so that it will recocnise thigs like the admin and manager directory?  

Thanks.

----------

