tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From André Warnier ...@ice-sa.com>
Subject Re: I have a problem with Apache, Tomcat
Date Mon, 04 May 2009 17:50:21 GMT
Hi Chris too, and hi nohacks.

I was not quite convinced by Chris's explanation, so I tested this by 
myself.
Apache httpd 2.2.3
mod_jk 1.2.18  (quite old)
Tomcat 5.5.27

In my case, URI's starting with /starweb are being redirected to Tomcat 
by mod_jk (corresponding to the OP's case "/myapp").
I also set the JkLogLevel to "debug" for this test.

Then I accessed a URI that is re-directed to Tomcat, but fetches a 
static html page there (that same page does not exist under Apache 
httpd's DocumentRoot):
http://myhost/starweb/starlog4_example_static.html

That worked fine of course, delivered by Tomcat.
Then I added a dummy jsessionid to the URI, as follows :
http://myhost/starweb/starlog4_example_static.html;jsessionid=blabla
and tried again.
That also returned the page from Tomcat, no problem.

In the mod_jk logfile, I find this (edited, because there is at lot more 
at the debug level) :

[Mon May 04 19:03:28 2009] [7189:47328] [debug] 
map_uri_to_worker::jk_uri_worker_map.c (502): Removing Session path 
';jsessionid=blabla' URI '/starweb/starlog4_example_static.html'
[Mon May 04 19:03:28 2009] [7189:47328] [debug] 
map_uri_to_worker::jk_uri_worker_map.c (508): Attempting to map URI 
'/starweb/starlog4_example_static.html;jsessionid=blabla' from 13 maps
[Mon May 04 19:03:28 2009] [7189:47328] [debug] 
map_uri_to_worker::jk_uri_worker_map.c (520): Attempting to map context 
URI '/servlets-examples/*'
[Mon May 04 19:03:28 2009] [7189:47328] [debug] 
map_uri_to_worker::jk_uri_worker_map.c (520): Attempting to map context 
URI '/starweb/*'
[Mon May 04 19:03:28 2009] [7189:47328] [debug] 
map_uri_to_worker::jk_uri_worker_map.c (534): Found a wildchar match 
ajp13 -> /starweb/*
[Mon May 04 19:03:28 2009] [7189:47328] [debug] jk_handler::mod_jk.c 
(1832): Into handler jakarta-servlet worker=ajp13 r->proxyreq=0
[Mon May 04 19:03:28 2009] [7189:47328] [debug] 
wc_get_worker_for_name::jk_worker.c (111): found a worker ajp13
[Mon May 04 19:03:28 2009] [7189:47328] [debug] wc_maintain::jk_worker.c 
(301): Maintaining worker ajp13
[Mon May 04 19:03:28 2009] [7189:47328] [debug] 
init_ws_service::mod_jk.c (531): Service protocol=HTTP/1.1 method=GET 
host=(null) addrr=192.168.245.129 name=myhost.company.com port=80 
auth=(null) user=(null) laddr=192.168.245.20 raddr=192.168.245.129
[Mon May 04 19:03:28 2009] [7189:47328] [debug]

etc... (the rest shows the page being returned by Tomcat)

So, the above works, and at least for URI's supposed to be forwarded to 
Tomcat, nor Apache httpd nor mod_jk are confused by the ";jessionid=" 
appendix to the URI.
It's also interesting to note that mod_jk, when it is called by Apache 
to examine this URI and see if it wants to handle it, is smart enough to 
first remove the "jsessionid=xxx" portion, before comparing the URI to 
its list of things to forward.

Then I tried to access a document which is not redirected to Tomcat, but 
located under Apache httpd's DocumentRoot :
http://myhost/starlog4.html

That worked also fine, and was delivered by Apache httpd.
Then I added a "jsessionid" attribute to this request :

http://myhost/starlog4.html;jsessionid=blabla

and then Apache httpd indeed returned a "404 Not found" error.
So, despite my initial scepticism (for which I apologise), Chris turns 
out to be right.

The Apache error log shows :
[Mon May 04 19:21:16 2009] [error] [client 192.168.245.129] File does 
not exist: /var/www/develop/starlog4.html;jsessionid=blabla

So indeed, the error is caused by (carefully, one item at a time) :

- the browser accesses the Tomcat application
- the Tomcat application returns a page (login.jsf), *in which* there is 
a link to
/a4j_3_2_2-SNAPSHOTorg/richfaces/renderkit/html/css/basic_classes.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.jsf;jsessionid=7B8278D155437DE625509198918C08D4.tomcat2
- the browser thus issues a request to Apache to obtain this file
- somehow Apache + mod_jk do not thing that this URI should be forwarded 
to Apache, so Apache tries to serve it itself
- and it does not find this object under its DocumentRoot and thus 
returns a 404.

I don't think that mod_jk, even with the "JkStripSession" parameter on, 
will scan each page returned by Tomcat, and /in the content/ change 
these links to remove the ";jsessionid=..." part.

So the questions would be :
1) /why/ does the page returned by Tomcat contain the embedded <img> 
tags with a "....;jsessionid=...." URI ?
What puts that jession-id there ?
OR
2) what makes it so that when Tomcat returns that page, Apache+mod_jk 
think that this css URI does /not/ have to be forwarded to Tomcat ?

There must be, at the Apache level, a rogue JkUnMount or SetEnvIf no_jk 
rule that interferes there, in the sense of not being quite smart enough 
to know that this link /should/ be forwarded to Tomcat.

And if it should /not/ be forwarded to Tomcat after all, then you should 
use a smart RewriteRule that will strip the ";jsessionid.." from these 
URI's, before Apache attempts to find them locally.





nohacks wrote:
> Hi Chris,
> 
> I downloaded the new version of mod_jk
> 
> http://www.apache.org/dist/tomcat/tomcat-connectors/jk/binaries/linux/jk-1.2.28/i586/
> 
> [   ] mod_jk-1.2.28-httpd-2.2.X.so                               
> 21-Mar-2009 23:53  676K  
> 
> I am still having the same issues as you can see...
> 
> Any ideal what is going on here??
> 
> Thanks
> Phil
> 
> 
> 
> 78.124.0.12 - - [04/May/2009:11:24:32 -0400] "GET /login.jsf HTTP/1.1" 200
> 3370 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR
> 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0; FDM; .NET CLR 2.0.50727)"
> 
> ============  404 here  ===============
> 
> 78.124.0.12 - - [04/May/2009:11:24:33 -0400] "GET
> /a4j_3_2_2-SNAPSHOTorg/richfaces/renderkit/html/css/basic_classes.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.jsf;jsessionid=7B8278D155437DE625509198918C08D4.tomcat2
> HTTP/1.1" 404 7014 "http://www.myAppName.com/login.jsf" "Mozilla/4.0
> (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322;
> Media Center PC 4.0; FDM; .NET CLR 2.0.50727)"
> 
> ============  404 here  ===============
> 
> 78.124.0.12 - - [04/May/2009:11:24:33 -0400] "GET
> /a4j_3_2_2-SNAPSHOTorg/richfaces/renderkit/html/css/extended_classes.xcss/DATB/eAF7sqpgb-jyGdIAFrMEaw__.jsf;jsessionid=7B8278D155437DE625509198918C08D4.tomcat2
> HTTP/1.1" 404 7014 "http://www.myAppName.com/login.jsf" "Mozilla/4.0
> (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322;
> Media Center PC 4.0; FDM; .NET CLR 2.0.50727)"
> 78.124.0.12 - - [04/May/2009:11:24:33 -0400] "GET /css/stylesheet.css
> HTTP/1.1" 304 - "http://www.myAppName.com/login.jsf" "Mozilla/4.0
> (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322;
> Media Center PC 4.0; FDM; .NET CLR 2.0.50727)"
> 78.124.0.12 - - [04/May/2009:11:24:33 -0400] "GET /js/jquery-1.2.3.pack.js
> HTTP/1.1" 304 - "http://www.myAppName.com/login.jsf" "Mozilla/4.0
> (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322;
> Media Center PC 4.0; FDM; .NET CLR 2.0.50727)"
> 78.124.0.12 - - [04/May/2009:11:24:33 -0400] "GET
> /js/jquery.jcarousel.pack.js HTTP/1.1" 304 -
> "http://www.myAppName.com/login.jsf" "Mozilla/4.0 (compatible; MSIE 7.0;
> Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0;
> FDM; .NET CLR 2.0.50727)"
> 78.124.0.12 - - [04/May/2009:11:24:33 -0400] "GET /css/jquery.jcarousel.css
> HTTP/1.1" 304 - "http://www.myAppName.com/login.jsf" "Mozilla/4.0
> (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322;
> Media Center PC 4.0; FDM; .NET CLR 2.0.50727)"
> 78.124.0.12 - - [04/May/2009:11:24:33 -0400] "GET /css/skin.css HTTP/1.1"
> 304 - "http://www.myAppName.com/login.jsf" "Mozilla/4.0 (compatible; MSIE
> 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC
> 4.0; FDM; .NET CLR 2.0.50727)"
> 78.124.0.12 - - [04/May/2009:11:24:34 -0400] "GET
> /images/prev-horizontal.png HTTP/1.1" 304 -
> "http://www.myAppName.com/login.jsf" "Mozilla/4.0 (compatible; MSIE 7.0;
> Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0;
> FDM; .NET CLR 2.0.50727)"
> 78.124.0.12 - - [04/May/2009:11:24:34 -0400] "GET
> /images/next-horizontal.png HTTP/1.1" 304 -
> "http://www.myAppName.com/login.jsf" "Mozilla/4.0 (compatible; MSIE 7.0;
> Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC 4.0;
> FDM; .NET CLR 2.0.50727)"
> 78.124.0.12 - - [04/May/2009:11:24:42 -0400] "POST
> /login.jsf;jsessionid=7B8278D155437DE625509198918C08D4.tomcat2 HTTP/1.1" 404
> 7014 "http://www.myAppName.com/login.jsf" "Mozilla/4.0 (compatible; MSIE
> 7.0; Windows NT 5.1; .NET CLR 1.0.3705; .NET CLR 1.1.4322; Media Center PC
> 4.0; FDM; .NET CLR 2.0.50727)"
> 
> 
> 
> 
> nohacks wrote:
>> Hi Chris,
>>
>> Thanks for your reply. I have JkStripSession on and still having the
>> issue. 
>>
>> Any help is really appreciated. I have had this issues for a long time now
>> and it is a Huge Issue for us !! 
>>
>> This is my httpd.conf file.
>>
>> ==================================
>> LoadModule jk_module /usr/lib/apache2/modules/mod_jk-1.2.27-httpd-2.2.6.so
>>
>> JkStripSession On
>>
>> JkMount /*.jsp loadbalancer
>> JkMount /*.jsf loadbalancer
>>
>> # JkMount /*.jsp ajp13
>> # JkMount /*.jsf ajp13
>>
>> JkWorkersFile workers.properties
>> JkShmFile     /var/log/httpd/mod_jk.shm
>> JkLogFile /opt/apache2log/mod_jk.log
>>
>> # JkLogLevel    info
>>
>> JkLogLevel    debug
>>
>> JkOptions     +ForwardURIEscaped
>> JkOptions     +ForwardDirectories
>>
>> FileETag None
>>
>> ExpiresDefault "access plus 4 weeks"
>>
>> # 480 weeks
>> <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
>> Header set Cache-Control "max-age=490304000, public"
>> </FilesMatch>
>>
>> ExpiresActive On
>> ExpiresByType image/gif A2592000
>> ExpiresByType image/png A2592000
>> ExpiresByType image/jpg A2592000
>> ExpiresByType image/jpeg A2592000
>>
>> =========== end of httpd.conf ===========
>>
>>
>>
>>
>> Christopher Schultz-2 wrote:
>>> -----BEGIN PGP SIGNED MESSAGE-----
>>> Hash: SHA1
>>>
>>> Nohacks,
>>>
>>> On 4/30/2009 4:18 PM, nohacks wrote:
>>>> You can see from my logs that apache returns a 200 for my login page
>>>> then
>>>> returns a 404 from
>>>>
>>>> It seems to be an issue now and then. It works for a while then it
>>>> tosses a
>>>> 404. Maybe after a timeout I really dont know...Hard to recreate. but my
>>>> logs are full of 404 jsessionid issues...
>>> I can tell you how to recreate it:
>>>
>>> 1. Log out of your application
>>> 2. Go to the login page
>>>
>>> Result: your httpd logs are full of 404 errors for things like
>>> mystylesheet.css;jsessionid=32456789 and
>>> myloginimage.png;jsessionid=32456789.
>>>
>>> The problem is that httpd thinks the ";jsesionid" is part of the path of
>>> the resource, instead of a parameter. You can fix this either with
>>> mod_rewrite (which is a bit heavy-handed) or you can use
>>>
>>> JkStripSession On
>>>
>>> if you are using a reasonably recent version of mod_jk.
>>>
>>> Hope that helps,
>>> - -chris
>>> -----BEGIN PGP SIGNATURE-----
>>> Version: GnuPG v1.4.9 (MingW32)
>>> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>>>
>>> iEYEARECAAYFAkn7UTEACgkQ9CaO5/Lv0PDwwgCcCjjHgsZI6oSDizZPpPxgMoD7
>>> d+4An1SWaF/2Q32jyK2DiULpvPRWB4Hn
>>> =iKFe
>>> -----END PGP SIGNATURE-----
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>>> For additional commands, e-mail: users-help@tomcat.apache.org
>>>
>>>
>>>
>>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message