Bug 40151 - mod_jk with Apache doesn't handle jsessionid encoded directory URLs
Summary: mod_jk with Apache doesn't handle jsessionid encoded directory URLs
Status: RESOLVED INVALID
Alias: None
Product: Tomcat Connectors
Classification: Unclassified
Component: Common (show other bugs)
Version: unspecified
Hardware: All Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-01 11:23 UTC by Damon Maria
Modified: 2008-10-05 03:09 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Damon Maria 2006-08-01 11:23:14 UTC
URLs of the form http://www.example.com/dir/;jsessionid=328s1t1289qrt (where
you'd expect the welcome file to be served up) don't work with mod_jk and Apache
2.2.3. Apache returns a 404 and adds the following to the error log: 
File does not exist: /wwwroot/dir/;jsessionid=328s1t1289qrt

Without the jsessionid part (http://www.example.com/dir/) works fine.

I've tried this against mod_jk from Tomcat connectors 1.2.18.
Comment 1 Rainer Jung 2006-08-05 16:55:36 UTC
Which Jk directives did you use, especially JkMount etc.?
Comment 2 Damon Maria 2006-08-07 02:26:29 UTC
Here's all my Jk directives from httpd.conf:

JkWorkersFile /opt/motorweb/conf/jetty/workers.properties
JkMount /*.jsp motorweb
JkMount /action/* motorweb
JkMount /reference/* motorweb
JkMount /robots.txt motorweb
JkMount /error/Send404 motorweb
JkMount / motorweb
JkEnvVar SSL_CLIENT_S_DN NONE

And I use the following to serve up directories:

DirectoryIndex welcome.jsp
Comment 3 David Rees 2006-09-09 01:10:50 UTC
I swear that adding something like this was working for me 2 weeks ago, but now
it doesn't work, I think I'm going crazy! Can you try adding this to your Apache
config?

<LocationMatch "/.*;jsessionid=.*">
	JkMount motorweb
</LocationMatch>
Comment 4 David Rees 2006-09-13 23:49:25 UTC
Here's a hack so that at least you don't get a 404, but you will lose your
session if the client was depending on the URL rewrite with jsessionid:

RewriteEngine On
RewriteRule ^(/.*);jsessionid=.*$ $1 [PT]

It just strips off the jsessionid for any directory request which has it and
passes the URL through.
Comment 5 Mladen Turk 2006-09-14 05:55:02 UTC
See the explanation on tomcat dev list.
The SetHandler jakarta-servlet works with Apache2+

<LocationMatch "/.*;jsessionid=.*">
  SetHandler jakarta-servlet
</LocationMatch>

In that case your worker list should look like:
worker.list=motorweb[,...]
Comment 6 Rainer Jung 2006-09-14 17:55:06 UTC
First of all, your problem description is inconsistent. The details are important.

You gave an example URL without a config, and afterwards a config, but the
example URL does not fit to this config. So we have to guess, which URL you
really mean.

I canot reproduce the problem, and I do't understand why any config workaround
should be necessary.

I used Apache 2.2.3 with mod_jk 1.2.18 and the following configuration:

JkWorkersFile conf/workers.properties
JkShmFile run/mod_jk.shm
JkLogFile logs/mod_jk.log
JkLogLevel trace
JkMount / motorweb
JkMount /*.jsp motorweb

and in workers.properties:

worker.list=motorweb
worker.motorweb.host=mytchost
worker.motorweb.port=28313
worker.motorweb.type=ajp13

Then I added an index.jsp into the top level directory of the ROOT context and
send the following URL to apache:

'fraxinus:8080/;jsessionid=a'

And voila: it returned the correct index.jsp. The mod_jk log file correctly showed:

[Thu Sep 14 19:50:15 2006] [5572:63840] [trace]
map_uri_to_worker::jk_uri_worker_map.c (481): enter
[Thu Sep 14 19:50:15 2006] [5572:63840] [debug]
map_uri_to_worker::jk_uri_worker_map.c (502): Removing Session path
';jsessionid=a' URI '/'
[Thu Sep 14 19:50:15 2006] [5572:63840] [debug]
map_uri_to_worker::jk_uri_worker_map.c (508): Attempting to map URI
'/;jsessionid=a' from 2 maps
[Thu Sep 14 19:50:15 2006] [5572:63840] [debug]
map_uri_to_worker::jk_uri_worker_map.c (520): Attempting to map context URI '/*.jsp'
[Thu Sep 14 19:50:15 2006] [5572:63840] [debug]
map_uri_to_worker::jk_uri_worker_map.c (520): Attempting to map context URI '/'
[Thu Sep 14 19:50:15 2006] [5572:63840] [debug]
map_uri_to_worker::jk_uri_worker_map.c (545): Found an exact match motorweb -> /
[Thu Sep 14 19:50:15 2006] [5572:63840] [trace]
map_uri_to_worker::jk_uri_worker_map.c (548): exit
[Thu Sep 14 19:50:15 2006] [5572:63840] [trace] jk_handler::mod_jk.c (1778): enter
[Thu Sep 14 19:50:15 2006] [5572:63840] [debug] jk_handler::mod_jk.c (1832):
Into handler jakarta-servlet worker=motorweb r->proxyreq=0
[Thu Sep 14 19:50:15 2006] [5572:63840] [trace]
wc_get_worker_for_name::jk_worker.c (101): enter
[Thu Sep 14 19:50:15 2006] [5572:63840] [debug]
wc_get_worker_for_name::jk_worker.c (111): found a worker motorweb
[Thu Sep 14 19:50:15 2006] [5572:63840] [trace]
wc_get_worker_for_name::jk_worker.c (113): exit
[Thu Sep 14 19:50:15 2006] [5572:63840] [trace] wc_maintain::jk_worker.c (287):
enter
[Thu Sep 14 19:50:15 2006] [5572:63840] [debug] wc_maintain::jk_worker.c (301):
Maintaining worker motorweb
[Thu Sep 14 19:50:15 2006] [5572:63840] [trace] ajp_maintain::jk_ajp_common.c
(2198): enter
[Thu Sep 14 19:50:15 2006] [5572:63840] [trace] ajp_maintain::jk_ajp_common.c
(2206): exit
[Thu Sep 14 19:50:15 2006] [5572:63840] [trace] wc_maintain::jk_worker.c (312): exit
[Thu Sep 14 19:50:15 2006] [5572:63840] [debug] init_ws_service::mod_jk.c (531):
Service protocol=HTTP/1.1 method=GET host=(null) addrr=192.168.0.69
name=fraxinus port=8080 auth=(null) user=(null) laddr=192.168.0.69
raddr=192.168.0.69

So if you can reproduce your problem, please describe correctly your config
including workers.properties, and your test case including expected and observed
behaviour. Finaly please attach the jk log file in trace level.

I keep this ticket as invalid as long as there is no other information available.
Comment 7 David Rees 2006-09-14 18:19:36 UTC
(In reply to comment #6)
> JkMount / motorweb
> JkMount /*.jsp motorweb
>
> Then I added an index.jsp into the top level directory of the ROOT context and
> send the following URL to apache:
> 
> 'fraxinus:8080/;jsessionid=a'

That configuration works for your example, but the reported did not use JkMount
/ motorweb. While that correctly gets links to / which are rewritten working,
you would have to add a JkMount /<dirname>/ motorweb for each directory in your
document root. So for example:

'fraxinus:8080/somedir/;jsessionid=a'

Will return a 404.

I am not the original reporter, but I have the same problem which I have been
discussing on the dev list.

Perhaps this should be left closed and a new bug opened for an enhancement
request to add functionality to mod_jk to allow you to map all URLs with
jsessionid to it.
Comment 8 Damon Maria 2006-09-18 10:38:24 UTC
The following suggestion doesn't work for me:

<LocationMatch "/.*;jsessionid=.*">
	JkMount motorweb
</LocationMatch>

The hack that involves a RewriteRule isn't really suitable as I need the
sessions in these pages.

The following suggestion is working fine:

<LocationMatch "/.*;jsessionid=.*">
  SetHandler jakarta-servlet
</LocationMatch>

I'm happy for this issue to be closed if an enhancement is opened for mod_jk to
perform something similar as suggested by David Rees.
Comment 9 Peter Rossbach 2006-09-18 10:44:31 UTC
Have you seen the last checkin's from Rainer?

He has fix that issue. Please, test with newst version http://tomcat.apache.org/dev/dist/tomcat-
connectors/jk/source/jk-1.2.19/

Peter
Comment 10 David Rees 2006-09-18 22:07:04 UTC
I can confirm that 1.2.19 provides a good solution to the jsessionid problem in
my  setup.

Damon, will you try adding this to your config?

<LocationMatch "/.*;jsessionid=.*">
 SetEnv JK_WORKER_NAME motorweb
 SetHandler jakarta-servlet
</LocationMatch>
Comment 11 Damon Maria 2006-09-18 22:20:06 UTC
I had a look through the 1.2.19 change log and couldn't find anything that
seemed relevant. 

I already have the following with 1.2.18 which works:

<LocationMatch "/.*;jsessionid=.*">
 SetHandler jakarta-servlet
</LocationMatch>

I can add "SetEnv JK_WORKER_NAME motorweb" to it. I presume this is in case I
have more than one worker in my worker.list? I only have the one worker
"motorweb" at present.

Is the above intended to be the final solution to this problem?
Comment 12 David Rees 2006-09-18 22:25:27 UTC
(In reply to comment #11)
> I can add "SetEnv JK_WORKER_NAME motorweb" to it. I presume this is in case I
> have more than one worker in my worker.list?

Yes, that is correct.

> I only have the one worker "motorweb" at present.
> Is the above intended to be the final solution to this problem?

I think so!
Comment 13 Sudhir Movva 2007-02-14 13:46:54 UTC
Hi, 
NOTE: I am not the reporter of the bug. I want to add another scenario for the 
same issue.
I had a similar issue where tomcat returned 404 when there was ;jsessionid= in 
the URL. I was using mod_jk 1.2.14 and upgraded to 1.2.20 and expected the 
issue to be fixed but the upgrade did not fix the issue.
The "gotcha" in my case was I had JkOptions +ForwardURIEscaped set and when I 
removed this option, I got the expected results even without the 
<LocationMatch> configuration.
Hope this helps some lost soul trying to figure this out.
Thanks,
Sudhir Movva.