tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 45442] New: Thread.currentThread.getClassLoader() wrong when looking up Resources
Date Sun, 20 Jul 2008 22:27:19 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=45442

           Summary: Thread.currentThread.getClassLoader() wrong when looking
                    up Resources
           Product: Tomcat 6
           Version: unspecified
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: dave@plaudit.com


I am using jboss 4.2.2 which as tomcat 6 embedded in it.

In tomcat you can specify a Resources class in context.xml. 'Resources' is used
to lookup resources (html, css, etc.). (more info on Resources at
http://tomcat.apache.org/tomcat-5.5-doc/config/resources.html)

Normally when your Resources class is called to lookup resourecs the thread's
classloader (Thread.currentThread.getClassLoader()) is set to the classloader
of the webapp as expected. Early on in a httpservletrequest tomcat runs through
some rules that are in the method internalMapWrapper of
org.apache.tomcat.util.http.mapper.Mapper (eg. looks to see if its a
welcomefile request, requesting a directory, etc.). When these rules are ran
the thread's classloader is NOT set to the webapp's classloader.

This inconsistency in the thread's classloader when running "Resources" can
should be fixed.

For me this caused random 404 responses. I received "random" 404 responses
because lookup calls to Resources class are cached by ProxyDirContxt.
ProxyDirContext wraps your "Resourcse" class. My Resources uses classes from
the webapps classloader.  Because of the inconsistency in the classloader my
Resources would sometimes say the resource doesn't exist, and in other does
exist -- depending no where the lookup takes place. The result of the lookup
would then be cached for something like 500ms.

As a temporarly solution i have overrode isCached() to always return false.
This causes ProxyDirContext to never cache the results.

When Resources lookup is done by
org.apache.tomcat.util.http.mapper.Mapper.internalMapWrapper(...),
Thread.currentThread.getClassLoader() should return the classloader of the
webapp.

Thanks


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


Mime
View raw message