Hi,

I did some digging and fixed my problem, but I am not sure that I covered
all apects and how should I proceed to release those changes and possibly
provide a test case to make sure it is tested in the future.

The changes were mainly to XMLClassDescriptorImpl where getFieldDescriptor
was overloaded to add passing the location (XMLClassDescriptor and
MarshallFramework were also changed to support the new method signature).
When checking for a field, a match takes into consideration the location
passed in compared to the field.

In UnmarshallHandler, in startElement when looking for the correct field
descriptor, if a path exist, it is passed to getFieldDescriptor in order to
select the right field.

Please advise.

Alain Picard


-----Original Message-----
From: Alain Picard [mailto:[EMAIL PROTECTED]
Sent: Sunday, March 28, 2004 12:19 AM
To: [EMAIL PROTECTED]
Subject: [castor-dev] NullPointer exception on "Duplicate Element"



Hi,

I am trying to unmarshall a RosettaNet PO that I have mapped to a pretty
flat structure and I am getting the following error while unmarshalling
(with debug):
#startElement: LineNumber
#characters: 1
#endElement: LineNumber
java.lang.NullPointerException
        at
org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.ja
va:900)
        at
org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.ja
va:1038)
        at
org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1403)
        at
org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLVa
lidator.java:1436)
        at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.disp
atch(XMLDocumentScanner.java:1205)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS
canner.java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1035)
        at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:605)
        at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:513)
        at POTestReq.main(POTestReq.java:32)

I am also set to IgnoreExtraElements.

Looking at the source, this error is happening while an exception message is
being constructed due to the fact that an element occured more than once.

I played a bit with the file but what seems to be happening is that I have
more that one field mapping that binds to the same name but at a different
location (this happens in many place in the file due to the way RosettaNet
has structured its element, and the exception can be triggered in other
areas as well).

Example:
<class name="com.hp.ibs.oneworld.placeorder.helper.PORequestLineItem">
        <field name="parentItemNbr" type="string">
            <bind-xml name="FreeFormText" location="comments"
node="element"/>
        </field>

        <field name="itemNbr" type="string">
            <bind-xml name="LineNumber" location="DocumentLineReference"
node="element"/>
        </field>
....
        <field name="isDropShip" type="string">
            <bind-xml name="AffirmationIndicator" location="isDropShip"
node="element"/>
        </field>

        <field name="lineNbr" type="string">
            <bind-xml name="LineNumber" node="element"/>
        </field>

Isn't a bind name unique by the combination of its location and name, or
simply its name?

How can I avoid this issue ?

Thanks for your help.

Alain Picard

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

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

Reply via email to