You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by John Yates <jw...@pacbell.net> on 2005/08/15 22:23:31 UTC

[daemon] classloader and jsvc

I recently tracked down a NullPointerException in my jsvc loaded java  
application to the fact that Thread.getContextClassLoader() returning  
null.  JAXBContext.newInstance(String contextPath) effectively is  
JAXBContext.newInstance(contextPath, Thread.getContextClassLoader())  
and dies if the class loader is null.  For my application, a fix was

   if (Thread.getContextClassLoader() == null) {
     Thread.setContextClassLoader(ClassLoader.getSystemClassLoader());
   }

My question:  is this is bug?  If so, where?  Should jsvc, since it  
loads the application, do this for me?  Should JAXB do this (it  
should perhaps provide more info when this happens - it took  
debugging to find it)? 
  

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


Re: [daemon] classloader and jsvc

Posted by John Yates <jw...@pacbell.net>.
As I prepare to do so I realize it was on the Windows side with  
procrun that I had the problem, not with jsvc.  I apologize to anyone  
who might have been trying to chase this down over there (unless, of  
course, its there as well!).

As penance for this mistake I will see if the problem IS on the jsvc  
side as well and include that in the bug report if appropriate.

John

On Aug 22, 2005, at 10:25 PM, Jean-frederic Clere wrote:

> John Yates wrote:
>
>
>> I recently tracked down a NullPointerException in my jsvc loaded  
>> java  application to the fact that Thread.getContextClassLoader()  
>> returning  null.  JAXBContext.newInstance(String contextPath)  
>> effectively is  JAXBContext.newInstance(contextPath,  
>> Thread.getContextClassLoader())  and dies if the class loader is  
>> null.  For my application, a fix was
>>
>>   if (Thread.getContextClassLoader() == null) {
>>     Thread.setContextClassLoader(ClassLoader.getSystemClassLoader());
>>   }
>>
>> My question:  is this is bug?  If so, where?  Should jsvc, since  
>> it  loads the application, do this for me?  Should JAXB do this  
>> (it  should perhaps provide more info when this happens - it took   
>> debugging to find it)?
>>
>
> Please add a bug report in bugzilla, so that the problem is not  
> forgotten in the next release.
>
> Cheers
>
> Jean-Frederic
>
>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>>
>>
>>
>
>


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


Re: [daemon] classloader and jsvc

Posted by Jean-frederic Clere <jf...@telefonica.net>.
John Yates wrote:

> I recently tracked down a NullPointerException in my jsvc loaded java  
> application to the fact that Thread.getContextClassLoader() returning  
> null.  JAXBContext.newInstance(String contextPath) effectively is  
> JAXBContext.newInstance(contextPath, Thread.getContextClassLoader())  
> and dies if the class loader is null.  For my application, a fix was
>
>   if (Thread.getContextClassLoader() == null) {
>     Thread.setContextClassLoader(ClassLoader.getSystemClassLoader());
>   }
>
> My question:  is this is bug?  If so, where?  Should jsvc, since it  
> loads the application, do this for me?  Should JAXB do this (it  
> should perhaps provide more info when this happens - it took  
> debugging to find it)?  

Please add a bug report in bugzilla, so that the problem is not 
forgotten in the next release.

Cheers

Jean-Frederic

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


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


Re: [daemon] classloader and jsvc

Posted by robert burrell donkin <rd...@apache.org>.
On Mon, 2005-08-15 at 22:23 +0200, John Yates wrote:
> I recently tracked down a NullPointerException in my jsvc loaded java  
> application to the fact that Thread.getContextClassLoader() returning  
> null.  JAXBContext.newInstance(String contextPath) effectively is  
> JAXBContext.newInstance(contextPath, Thread.getContextClassLoader())  
> and dies if the class loader is null.  For my application, a fix was
> 
>    if (Thread.getContextClassLoader() == null) {
>      Thread.setContextClassLoader(ClassLoader.getSystemClassLoader());
>    }
> 
> My question:  is this is bug?  If so, where?  Should jsvc, since it  
> loads the application, do this for me?  Should JAXB do this (it  
> should perhaps provide more info when this happens - it took  
> debugging to find it)? 

the context classloader may be null but should be set (where possibly)
by well behaved applications. IMHO it's a bug in JAXB (should null check
and use the system) but it would be good if jsvc set something
reasonable. 

- robert