I try to unmarshal a castor object from XML and get a
NullPointerException in XMLClassDescriptorImpl.
I'm using castor 0.9.3.19. 

With an older version 0.9.3 from 03.07.01 it works fine. But because of
the
memory leak in this old version we are upgrading to the new one. 

Some other parts of the code are working fine with the new version.
Even the same schema as below, just with another Castor Object (Order
instead of DebitorenStammdaten) works fine.

I carefully read the XML documents and can't detect any errors. Because
it's fine with the old version, I even think there are no errors.

My code is this one:

        public Object convert2Object( InputStream is, Class objClass )
        {
                doValidation = false;
                try
                {
                        xmlInp = new InputStreamReader( is,
OurConstants.ENCODING );
                } catch ( Exception e )
                {
                        ExceptionHandler.handleIt( e, "Wrong Encoding
for XMLIn" );
                        xmlInp = new InputStreamReader( is );
                }
                xmlInp = new BufferedReader( xmlInp );
                unMrs = new Unmarshaller( objClass );
                unMrs.setValidation( false );

        // DEBUG:
        unMrs.setDebug(true);
        unMrs.setIgnoreExtraAttributes(true);
        PrintWriter pw = new PrintWriter(System.out, true);
        unMrs.setLogWriter(pw);
        
        return unMrs.unmarshal( xmlInp );
        }

called via:
DebitorenStammdaten defCustomer = new DebitorenStammdaten();
...
DebitorenStammdaten customer = ( DebitorenStammdaten ) convert2Object(
OurConstants.getDefaultCustomerXML(), defCustomer.getClass() ) );

        => NullPointerException
        
Order order = ( Order ) convert2Object(
OurConstants.getDefaultOrderXML(), defOrder.getClass() ) );
        => fine!!!


The exception is thrown in the unmarshal method right at the end.
Here is the stack trace:
java.lang.NullPointerException
        at
org.exolab.castor.xml.util.XMLClassDescriptorImpl.getFieldDescriptor(XML
ClassDescriptorImpl.java:372)
        at
org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.jav
a:940)
        at
org.apache.xerces.parsers.SAXParser.startElement(SAXParser.java:1335)
        at
org.apache.xerces.validators.common.XMLValidator.callStartElement(XMLVal
idator.java:824)
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatc
h(XMLDocumentScanner.java:1222)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScan
ner.java:380)
        at
org.apache.xerces.framework.XMLParser.parse(XMLParser.java:900)
        at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:463)
        at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:395)
        at
de.cominto.sap.convert.XML2Object.convert2Object(XML2Object.java:72)
        at
de.cominto.sap.GenerateCustomer.generateCustomer(GenerateCustomer.java:4
6)
        at
de.cominto.sap.connectors.SAPQueue.validateCfg(SAPQueue.java:294)
        at de.cominto.sap.connectors.SAPQueue.<init>(SAPQueue.java:73)
        at
de.cominto.deutschepost.paymenthandler.PaymentHandler.main(PaymentHandle
r.java:114)


I added some debugging to XMLClassDescriptorImpl below line 360 
System.err.println("desc name = " + desc.getXMLName());
System.err.println("desc prefix = " + desc.getNameSpacePrefix());
System.err.println("desc uri = " + desc.getNameSpaceURI());
System.err.println("node name = " + desc.getNodeType().toString());
System.err.println("xcd = " + xcd);

and got theese results:
desc name = -error-if-this-is-used-
desc prefix = null
desc uri = null
node name = element
xcd = null      
        => which causes the error when xcd.getFieldDescriptor(name,
NodeType.Element) is accessed


Does anyone know, where's the problem???
What's going on here?
I think a NullPointerException in this place should never be caused.

Many thanks in advance.

        Torsten

eMail: [EMAIL PROTECTED]

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to