commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robert burrell donkin <>
Subject Re: [daemon] classloader and jsvc
Date Tue, 16 Aug 2005 20:52:53 GMT
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

- robert

View raw message