History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: CASTOR-2172
Type: Bug Bug
Status: Open Open
Priority: Critical Critical
Assignee: Unassigned
Reporter: Iñaki Iturrate
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
castor

"Element passed to type null" when using choice-sequence-choice elements

Created: 24/Sep/07 05:36 AM   Updated: 28/Sep/07 03:12 AM
Component/s: XML code generator
Affects Version/s: 1.2, 1.1.2.1
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive generated_code.zip (21 kb)
2. Text File patch.c2174.tests.20070928.txt (5 kb)
3. Zip Archive test_case.zip (0.6 kb)
4. File xsdUsed.xsd (2 kb)

Environment: JDK 1.4, Eclipse 3.2

Testcase included: yes


 Description  « Hide
I generated a code from a XML Schema (i've attached both generated code and schema).
I think that the problem is here:

<element name="Subject" type="saml:SubjectType"/>
<complexType name="SubjectType">
<choice>
<sequence>
<choice>
<element name="choice1" type="string"/>
<element name="choice2" type="string"/>
<element name="choice3" type="string"/>
</choice>
<element ref="saml:SubjectConfirmation" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<element ref="saml:SubjectConfirmation" maxOccurs="unbounded"/>
</choice>
</complexType>

When I create a Subject element and marhsal it, it's ok, but then I try to unmarhsal it, it throws an exception:

org.exolab.castor.xml.MarshalException: Element with name SubjectConfirmation passed to type null in incorrect order; expected element has to be member of the expected choice.{File: [not available]; line: 2; column: 133}
at org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:755)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:721)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:610)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:801)
at test.saml.Subject.unmarshal(Subject.java:100)
at test.Test.testSubject(Test.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: ValidationException: Element with name SubjectConfirmation passed to type null in incorrect order; expected element has to be member of the expected choice.
at org.exolab.castor.xml.util.XMLClassDescriptorImpl.checkDescriptorForCorrectOrderWithinSequence(XMLClassDescriptorImpl.java:362)
at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1868)
at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1995)
at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1351)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:709)
... 22 more
Caused by: ValidationException: Element with name SubjectConfirmation passed to type null in incorrect order; expected element has to be member of the expected choice.
at org.exolab.castor.xml.util.XMLClassDescriptorImpl.checkDescriptorForCorrectOrderWithinSequence(XMLClassDescriptorImpl.java:362)
at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1868)
at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1995)
at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1351)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:709)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:610)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:801)
at test.saml.Subject.unmarshal(Subject.java:100)
at test.Test.testSubject(Test.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at junit.framework.TestCase.runTest(TestCase.java:154)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:128)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)

I've attached the testCase that creates the subject and then marhsal and unmarhsal it.

Regards
Iņaki Iturrate



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Werner Guttmann - 24/Sep/07 05:57 AM
Sorry, but can you please attach a working JUnit test case that allows to easily replay your problem. Please read the guidelines available at http://castor.org/how-to-submit-an-xml-bug.html at least.

If you are looking at the odd 70 Jira issues (all of them with more or less complex XML schema fragments), how much time would you want to spend on dreaming up test case code ?


Iñaki Iturrate - 24/Sep/07 06:14 AM
Sorry about that. For some reason the files hadn't be attached properly.
I've attached them again.
Thank you

Iñaki Iturrate - 25/Sep/07 01:57 AM
Hi again.

I removed the choice-sequence-choice in xsd's, and it works. So apparently there's a problem with that.
I mean, there's no problem, I''ll work with these xsd's 'til someone find a solution.
Cheers


Werner Guttmann - 28/Sep/07 02:33 AM
JUnit test case relative to codegen/src/test.

Werner Guttmann - 28/Sep/07 02:46 AM
It looks like there's a problem with validation of the 'first' choice within the SubjecType complex type definition.

Werner Guttmann - 28/Sep/07 02:51 AM
In the SubjecTypeDescriptor class, both field descriptors for both (possible) choice elements are set to required, which in the context of a choice looks ... well, odd.

Iñaki Iturrate - 28/Sep/07 03:01 AM
I've readed the minOccurs=0-bug, so it's possible that it also crashes because of that bug (apart from this bug), isn't it?
Cheers

Werner Guttmann - 28/Sep/07 03:12 AM
No, it looks like it is not related to the minOccurs attribute, as the error occurs within the SubjectTypeDescriptor, and not the SubjectComparisonTypeDescriptor.