jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • castor
  • CASTOR-204

Invalid Instance Document containing ALL elements of a schema definitions choice is not unmarshallable

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical 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)
...

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Keith Visco added a comment - 18/Nov/02 12:50 PM

Stefan,

Do you have a test case that doesn't rely on JDOM?

Also have you tried your test against 0.9.4.1?

Show
Keith Visco added a comment - 18/Nov/02 12:50 PM Stefan, Do you have a test case that doesn't rely on JDOM? Also have you tried your test against 0.9.4.1?
Hide
Permalink
stefan schwickert added a comment - 19/Nov/02 2:48 AM

Created an attachment (id=176)
TestCase to reproduce behaviour with castor 0.9.3.21 and 0.9.4.1

Show
stefan schwickert added a comment - 19/Nov/02 2:48 AM Created an attachment (id=176) TestCase to reproduce behaviour with castor 0.9.3.21 and 0.9.4.1
Hide
Permalink
stefan schwickert added a comment - 19/Nov/02 2:53 AM

Hello Keith,

I added zip file BUG1059, containing a test case that is not based on JDOM.
It contains everything (schemadefinition, casorbuilder.properties, sample xml
file) you need to reproduce the described behaviour for castor version 0.9.3.21
and above.

Show
stefan schwickert added a comment - 19/Nov/02 2:53 AM Hello Keith, I added zip file BUG1059, containing a test case that is not based on JDOM. It contains everything (schemadefinition, casorbuilder.properties, sample xml file) you need to reproduce the described behaviour for castor version 0.9.3.21 and above.
Hide
Permalink
Keith Visco added a comment - 19/Nov/02 11:32 AM

Thanks Stefan, I'll run your test case and look into the issues.

Show
Keith Visco added a comment - 19/Nov/02 11:32 AM Thanks Stefan, I'll run your test case and look into the issues.
Hide
Permalink
Edward Kuns added a comment - 12/Oct/06 8:36 PM

Used this issue to attach a test case to make sure that this bug – fixed an an unknown time in the past – stays fixed.

Show
Edward Kuns added a comment - 12/Oct/06 8:36 PM Used this issue to attach a test case to make sure that this bug – fixed an an unknown time in the past – stays fixed.

People

  • Assignee:
    Edward Kuns
    Reporter:
    stefan schwickert
Vote (0)
Watch (0)

Dates

  • Created:
    10/Oct/02 2:43 AM
    Updated:
    22/Oct/06 3:21 PM
    Resolved:
    12/Oct/06 8:36 PM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.