Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Critical
-
Resolution: Fixed
-
Affects Version/s: 0.9.3.21
-
Fix Version/s: None
-
Component/s: XML
-
Labels:None
-
Environment:Operating System: Windows 2000
Platform:
-
Bugzilla Id:1059
Description
I have a problem unmarshalling an INVALID instance document containing ALL
elements of a choice to the Castor generated Classes.
The following schema definition contains a choice.
I generated the source code using options
sourcegen -types j2
and
org.exolab.castor.builder.javaclassmapping=type
in castorbuilder.properties.
BAD: The unmarshalling of valid instance (using either TechUserPwd od
SessionId) documents wors fine. Whenever the instance document contains both
element of the choice (that means the document is invalid, see below) the
marshalling ends in a java.lang.StackOverflowError followed by an infinite loop
of messages (see below).
GOOD: This behavoiur is reproducible usind the following information
Schema definition:
<?xml version = "1.0" encoding = "ISO-8859-1"?>
<xsd:schema xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.dekabank.de/schemas/dbdzgs/request/"
elementFormDefault="qualified"
xmlns="http://www.dekabank.de/schemas/dbdzgs/request/">
<xsd:element name = "Request">
<xsd:complexType>
<xsd:sequence>
<xsd:element name = "TechUserId" type
= "xsd:string" minOccurs="1" maxOccurs="1"/>
<xsd:choice minOccurs="1" maxOccurs="1">
<xsd:element name = "TechUserPwd" type
= "xsd:string"/>
<xsd:element name = "SessionId" type
= "xsd:string"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
Invalid instance document:
<?xml version="1.0" encoding="UTF-8"?>
<Request xmlns="http://www.dekabank.de/schemas/dbdzgs/request/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SentAt>2002-08-18T10:01:00</SentAt>
<SenderId>2002-01-01</SenderId>
<RecipientId>2002-01-01</RecipientId>
<TrxId>2002-01-01</TrxId>
<Topic>2002-01-01</Topic>
<Version>6</Version>
<TechUserId>7</TechUserId>
<TechUserPwd>aaaaa</TechUserPwd>
<SessionId>312</SessionId>
</Request>
Test application:
import org.jdom.output.XMLOutputter;
import org.jdom.input.SAXBuilder;
import org.jdom.Document;
import java.io.IOException;
import org.jdom.JDOMException;
import org.jdom.output.DOMOutputter;
import org.exolab.castor.xml.Unmarshaller;
public class Test1 {
public static void main(String[] argv) {
try {
String filename = "choice.xml";
XMLOutputter xmloutputter = new XMLOutputter(" ", true);
SAXBuilder builder = new SAXBuilder();
Document jdomDoc = builder.build(filename);
DOMOutputter outputter = new DOMOutputter();
org.w3c.dom.Document w3cDoc = outputter.output(jdomDoc);
xmloutputter.output(jdomDoc, System.out);
Request req= (Request)Unmarshaller.unmarshal(Request.class, w3cDoc);
} catch (Exception e) {
e.printStackTrace();
}
}
}
This results in:
java.lang.StackOverflowError
at org.exolab.castor.util.List.toArray(Unknown Source)
at org.exolab.castor.util.List.toArray(Unknown Source)
at org.exolab.castor.xml.util.XMLClassDescriptorImpl.getElementDescriptors
(Unknown Source)
at org.exolab.castor.xml.util.XMLClassDescriptorImpl.canAccept(Unknown Source)
at org.exolab.castor.xml.UnmarshalHandler.startElement(Unknown Source)
at org.exolab.castor.xml.UnmarshalHandler.startElement(Unknown Source)
at org.exolab.castor.xml.UnmarshalHandler.startElement(Unknown Source)
at org.exolab.castor.xml.UnmarshalHandler.startElement(Unknown Source)
at org.exolab.castor.xml.UnmarshalHandler.startElement(Unknown Source)
at org.exolab.castor.xml.UnmarshalHandler.startElement(Unknown Source)
...
Stefan,
Do you have a test case that doesn't rely on JDOM?
Also have you tried your test against 0.9.4.1?