commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Henri Yandell (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DIGESTER-109) FromXmlRuleSet and SetNextRule classloader issue
Date Thu, 02 Nov 2006 01:47:17 GMT
    [ http://issues.apache.org/jira/browse/DIGESTER-109?page=comments#action_12446425 ] 
            
Henri Yandell commented on DIGESTER-109:
----------------------------------------

In line with VALIDATOR-206, Digester also has a setUseContextClassLoader(true) method. So
this should also be fixable by adding that call to your code.

It does raise the question of whether there is any time you wouldn't want the context class
loader to be used. Here's info on the ContextClassLoader:  http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html#getContextClassLoader()

Here's the Lang ClassUtils.getClass implementation:

    public static Class getClass(String className, boolean initialize) throws ClassNotFoundException
{
        ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
        ClassLoader loader = contextCL == null ? ClassUtils.class.getClassLoader() : contextCL;
        return getClass(loader, className, initialize );
    }

That would seem to imply that in the opinion of those who worked on that in Lang, that there's
no reason not to use it, though you still need a backup in case it's null.

> FromXmlRuleSet  and  SetNextRule  classloader issue
> ---------------------------------------------------
>
>                 Key: DIGESTER-109
>                 URL: http://issues.apache.org/jira/browse/DIGESTER-109
>             Project: Commons Digester
>          Issue Type: Bug
>            Reporter: Anna Komaristaia
>
> When I start the application in Unix, there are 2 classes cause the problem:
> 1)  The NullPointerException in "FromXmlRuleSet  " class in the method "addRuleInstances(Digester,
String)";
> 2)  The NullPointerException in "SetNextRule" class in the method "end()";
> Temporary solution
> ---------------------------
>  I recompiled the commons-digester jar with the next changes and it's working fine in
PC and Unix: 
> Changes in the "FromXmlRuleSet  " class 
>       
> 1)  public static final String DIGESTER_DTD_PATH = "digester-rules.dtd";
> 2)  in the method "addRuleInstances"  
>           the line 
>          URL dtdURL = getClass().getClassLoader().getResource(DIGESTER_DTD_PATH);
>         
>          changed by
>         
>          URL dtdURL = this.getClass().getResource(DIGESTER_DTD_PATH); 
> Changes In the "SetNextRule" class 
>         the line
>                  paramTypes[0] = digester.getClassLoader().loadClass( paramType);
>        changed by
>               if( digester.getClassLoader() == null )
>                     paramTypes[0] = Class.forName(paramType);
>               else
>                     paramTypes[0] = digester.getClassLoader().loadClass( paramType);
> Thanks, 
> //Anna 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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


Mime
View raw message