Thanks, Daniel, for taking the time to explain this.
Regards
Werner
Smith, Daniel wrote:
> Hi Werner,
>
> I found the problem by adding System.outs to ClassDescriptorResolverImpl
> around line 279:
>
> try {
> ClassLoader loader = type.getClassLoader();
> Class dClass = loadClass(className, loader);
> classDesc = (XMLClassDescriptor) dClass.newInstance();
> _cacheViaClass.put(type, classDesc);
> System.out.println("Thread[" +
> Thread.currentThread().getId() +"] class WAS found: " + className);
> }
> catch(ClassNotFoundException cnfe) {
> System.out.println("Thread[" +
> Thread.currentThread().getId() +"] class not found: " + className + ": "
> + cnfe.getMessage());
> cnfe.printStackTrace();
> /*
> This is ok, since we are just checking if the
> Class exists...if not we create one.
> */
> }
>
> I found that one thread got a ClassNotFoundException for a descriptor
> class and the other thread got an instance of the exact same class.
>
> Thread[9] class not found: com.stargus.ws.api.ResponseBodyDescriptor:
> com.stargus.ws.api.ResponseBodyDescriptor
> ...
> Thread[8] class WAS found: com.stargus.ws.api.ResponseBodyDescriptor
> Thread[8] end of ClassDescriptorResolverImpl.resolve
> ...
> Thread[9] end of ClassDescriptorResolverImpl.resolve
>
> That coupled with the fact that I couldn't reproduce the problem outside
> of tomcat makes me pretty sure tomcat is the cause.
>
> -----Original Message-----
> From: Werner Guttmann [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, May 02, 2006 11:55 AM
> To: [email protected]
> Subject: Re: [castor-user] RE: Null pointer while unmarshalling xml to
> generated classes
>
> Thanks, Dan, for letting us know. Having said that, I'd really like to
> learn how you came about to realize that Tomcat is the problem, indeed.
>
> Thanks
> Werner
>
> Smith, Daniel wrote:
>> I found the cause of my null pointer. It's actually caused by a bug in
>> the tomcat classloader:
>> http://issues.apache.org/bugzilla/show_bug.cgi?id=33743. One of the
>> threads gets a ClassNotFoundException trying to load one of my
> generated
>> descriptor classes in ClassDescriptorResolverImpl.resolve. It goes on
> to
>> use introspection, but something must be in an invalid state.
>>
>>
>> -Dan
>>
>> -----Original Message-----
>> From: Smith, Daniel
>> Sent: Monday, May 01, 2006 2:42 PM
>> To: '[email protected]'
>> Subject: Null pointer while unmarshalling xml to generated classes
>>
>> Hi,
>>
>> I'm getting a null pointer exception when unmarshalling xml to classes
>> generated from using the source generator. This exception only happens
>> if two threads are trying to unmarshal a document at the same time.
> One
>> of the threads will succeed and one will fail with this exception. As
>> far as I can tell it only happens the first time I try this after I
>> start the JVM. After the initial error everything works fine. I'm
> using
>> castor 1.0.
>>
>> I'm using the static Unmarshaller.unmarshal(Class, Node) method.
>>
>> Here's the stack trace:
>> java.lang.NullPointerException
>> at
>>
> org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:
>> 757)
>> at
>>
> org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.jav
>> a:249)
>> at
>>
> org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.jav
>> a:182)
>> at
>>
> org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProd
>> ucer.java:333)
>> at
>>
> org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.jav
>> a:247)
>> at
>>
> org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.jav
>> a:182)
>> at
>>
> org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProd
>> ucer.java:333)
>> at
>>
> org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.jav
>> a:247)
>> at
>>
> org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.jav
>> a:182)
>> at
>>
> org.exolab.castor.xml.util.DOMEventProducer.processChildren(DOMEventProd
>> ucer.java:333)
>> at
>>
> org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.jav
>> a:247)
>> at
>>
> org.exolab.castor.xml.util.DOMEventProducer.process(DOMEventProducer.jav
>> a:182)
>> at
>>
> org.exolab.castor.xml.util.DOMEventProducer.start(DOMEventProducer.java:
>> 110)
>> at
>> org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:584)
>> at
>> org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:735)
>> at
>> org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:848)
>> at
>>
> com.stargus.ws.DanTestWebServiceInput.processRequest(DanTestWebServiceIn
>> put.java:82)
>> at
>>
> com.stargus.ws.DanTestWebServiceInput.access$0(DanTestWebServiceInput.ja
>> va:75)
>> at
>>
> com.stargus.ws.DanTestWebServiceInput$1.run(DanTestWebServiceInput.java:
>> 55)
>>
>>
>> -------------------------------------------------
>> If you wish to unsubscribe from this list, please
>> send an empty message to the following address:
>>
>> [EMAIL PROTECTED]
>> -------------------------------------------------
>>
>>
>
>
> -------------------------------------------------
> If you wish to unsubscribe from this list, please
> send an empty message to the following address:
>
> [EMAIL PROTECTED]
> -------------------------------------------------
>
>
> -------------------------------------------------
> If you wish to unsubscribe from this list, please
> send an empty message to the following address:
>
> [EMAIL PROTECTED]
> -------------------------------------------------
>
>
-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:
[EMAIL PROTECTED]
-------------------------------------------------