You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Esteban Lorenzano <es...@yahoo.com> on 2003/09/30 16:36:58 UTC

Digester: Problems with ClassLoader

I am working with Digester inside an Application
Server (Oracle iAS), and I had some problems because
the method
DigesterRuleParser.IncludeRule.includeXMLRules, uses
the ClassLoader for the class DigesterRuleParser, not
the ClassLoader in use for the current thread (as this
is a container, is not the same ClassLoader for the
system jars and the application jars).
So, I just replace the line 368 of the file
DigesterRuleParser.java:
URL fileURL =
DigesterRuleParser.this.getClass().getClassLoader().getResource(fileName);

with the line:

URL fileURL =
Thread.currentThread().getContextClassLoader().getResource(fileName);

I think this can be useful, and my tests works fine,
maybe somebody wants to add this code to the
repository



=====
****************************************
* � Retroceder nunca, rendirse jam�s ! *
****************************************

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com

Re: Digester: Problems with ClassLoader

Posted by "Craig R. McClanahan" <cr...@apache.org>.
Esteban Lorenzano wrote:

>I am working with Digester inside an Application
>Server (Oracle iAS), and I had some problems because
>the method
>DigesterRuleParser.IncludeRule.includeXMLRules, uses
>the ClassLoader for the class DigesterRuleParser, not
>the ClassLoader in use for the current thread (as this
>is a container, is not the same ClassLoader for the
>system jars and the application jars).
>So, I just replace the line 368 of the file
>DigesterRuleParser.java:
>URL fileURL =
>DigesterRuleParser.this.getClass().getClassLoader().getResource(fileName);
>
>with the line:
>
>URL fileURL =
>Thread.currentThread().getContextClassLoader().getResource(fileName);
>
>I think this can be useful, and my tests works fine,
>maybe somebody wants to add this code to the
>repository
>  
>

Good catch!  I just applied a slight tweak to this patch (if there is no 
thread context class loader, fall back to the class loader that loaded 
this class) because not all Digester users are running in a container 
that supports the thread context class loader.  Fixed in nightly build 
20031001.

Thanks for the patch.

Craig



Re: Digester: Problems with ClassLoader

Posted by "Craig R. McClanahan" <cr...@apache.org>.
Esteban Lorenzano wrote:

>I am working with Digester inside an Application
>Server (Oracle iAS), and I had some problems because
>the method
>DigesterRuleParser.IncludeRule.includeXMLRules, uses
>the ClassLoader for the class DigesterRuleParser, not
>the ClassLoader in use for the current thread (as this
>is a container, is not the same ClassLoader for the
>system jars and the application jars).
>So, I just replace the line 368 of the file
>DigesterRuleParser.java:
>URL fileURL =
>DigesterRuleParser.this.getClass().getClassLoader().getResource(fileName);
>
>with the line:
>
>URL fileURL =
>Thread.currentThread().getContextClassLoader().getResource(fileName);
>
>I think this can be useful, and my tests works fine,
>maybe somebody wants to add this code to the
>repository
>  
>

Good catch!  I just applied a slight tweak to this patch (if there is no 
thread context class loader, fall back to the class loader that loaded 
this class) because not all Digester users are running in a container 
that supports the thread context class loader.  Fixed in nightly build 
20031001.

Thanks for the patch.

Craig



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