I think this is now fixed.   

Dan



On Apr 3, 2013, at 1:29 PM, Daniel Kulp <[email protected]> wrote:

> 
> On Apr 3, 2013, at 3:48 AM, Rex Wang <[email protected]> wrote:
> 
>> hi devs,
>> I found some intermittent NullpointerException, and it is very hard to
>> reproduce but I did have met a lot of times, and it is thrown from
>> different places from runtime:
>> Stack Dump = java.lang.NullPointerException
>>   at
>> org.apache.cxf.common.jaxb.JAXBUtils.generateJaxbSchemas(JAXBUtils.java:765)
>>   at
>> org.apache.cxf.jaxb.JAXBDataBinding.generateJaxbSchemas(JAXBDataBinding.java:440)
>>   at
>> org.apache.cxf.jaxb.JAXBDataBinding.initialize(JAXBDataBinding.java:363)
>>   at
>> org.apache.cxf.service.factory.AbstractServiceFactoryBean.initializeDataBindings(AbstractServiceFactoryBean.java:86)
>>   at
>> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.buildServiceFromClass(ReflectionServiceFactoryBean.java:469)
>>   at
>> org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean.buildServiceFromClass(JaxWsServiceFactoryBean.java:690)
>>   at
>> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.initializeServiceModel(ReflectionServiceFactoryBean.java:531)
>>   at
>> org.apache.cxf.service.factory.ReflectionServiceFactoryBean.create(ReflectionServiceFactoryBean.java:247)
>> 
>> After checking the codes, they are all about the jaxbcontext is null.
>> From the JAXBContextCache.CachedContextAndSchemas, I notice this line:
>> private WeakReference<JAXBContext> context;
>> 
>> IMHO, WeakReference is not a good choice to do cache, it could be gc in any
>> time. For example,
>> JAXBContextCache.getCachedContextAndSchemas(..)
>> <gc>
>> ctx = cachedContextAndSchemas.getContext()    <-- then the ctx will be null
>> here
>> 
>> So I guess this is the root cause of the intermittent issue. Any insights
>> or stories about the current design? Can we change it to SoftReference?
> 
> 
> A SoftReference wouldn't really change anything.  It would make the issue 
> occur less often, but it could still be garbage collected at any time.
> 
> There's definitely an issue here though.  I'll need to think about this some 
> more.  Not sure on the best fix right now.   Hmm…..  
> 
> 
> -- 
> Daniel Kulp
> [email protected] - http://dankulp.com/blog
> Talend Community Coder - http://coders.talend.com
> 

-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to