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

Key: CASTOR-2313
Type: Bug Bug
Status: Open Open
Priority: Blocker Blocker
Assignee: Werner Guttmann
Reporter: Ronald R. DiFrango
Votes: 0
Watchers: 1
Operations

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

org.exolab.castor.xml.MarshalException: Element with name {0} passed to type null in incorrect order;

Created: 18/Mar/08 08:05 AM   Updated: 24/Jun/08 07:12 AM
Component/s: XML, XML code generator, XML tools
Affects Version/s: 1.2
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. File castor.properties (0.3 kb)
2. Zip Archive CastorBug2313.zip (119 kb)
3. File castorbuilder.properties (0.3 kb)
4. Text File patch.c2312.20080318.txt (4 kb)

Environment: Windows; JDK 1.5; Standalone JUnit tests


 Description  « Hide
All,

I think I have hit the following bug and wanted confirmation that that is in fact the case:

http://jira.codehaus.org/browse/CASTOR-2172

Here is snippet of my XSD:

<xs:complexType name="ResponseType">
<xs:choice>
<xs:sequence>
<xs:element ref="ApplicationKey"/>
<xs:element ref="ApplicationLabel"/>
<xs:element ref="Status"/>
<xs:element ref="Applicant" minOccurs="0"/>
<xs:element ref="CoApplicant" minOccurs="0"/>
<xs:element ref="ProductType" minOccurs="0"/>
<xs:element ref="CreditLimit" minOccurs="0"/>
<xs:element ref="APR" minOccurs="0"/>
<xs:element ref="AccountNumber" minOccurs="0"/>
<xs:element ref="ChaseTransactionID" minOccurs="0"/>
<xs:element ref="CardExpirationDate" minOccurs="0"/>
<xs:element ref="VendorStatus" minOccurs="0"/>
</xs:sequence>
<xs:sequence>
<xs:element ref="Status">
<xs:annotation>
<xs:documentation>Carryover from Legacy (always Error for IC Web)</xs:documentation>
</xs:annotation>
</xs:element>
<xs:choice>
<xs:sequence>
<xs:element ref="Error"/>
<xs:element ref="ApplicationLabel" minOccurs="0"/>
</xs:sequence>
<xs:element ref="AppKey">
<xs:annotation>
<xs:documentation>Carryover from Legacy. Only present in a successful asynchronous response.</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
</xs:sequence>
</xs:choice>
</xs:complexType>

<xs:element name="CreditApplicationResponse">
<xs:annotation>
<xs:documentation>This document will be used for returning synchronous responses from the Credit Application Gateway</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:complexContent>
<xs:extension base="ResponseType"/>
</xs:complexContent>
</xs:complexType>
</xs:element>

And when I create the following XML:

<CreditApplicationResponse>
<Status>Dummy</Status>
<Error>
<text>Dummy</text>
</Error>
<ApplicationLabel>dummy</ApplicationLabel>
</CreditApplicationResponse>

I get the following exception:

org.exolab.castor.xml.MarshalException: Element with name Status passed to type null in incorrect order; expected element with name 'ApplicationKey' or any other optional element declared prior to it.{File: [not available]; line: 3; column: 10}

Is this the same problem and if so, how do I work around it?

Thanks,

Ron



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Ronald R. DiFrango - 18/Mar/08 08:10 AM
Just and FYI, I am not using a mapping file, but I am using an ANT task to generate the source code. I will submit the XSD along with an ANT script to build it for my tests.

Ronald R. DiFrango - 18/Mar/08 08:25 AM
Attached is what should be a full Ecplise project along with an ANT build to re-create the issue.

Werner Guttmann - 18/Mar/08 05:55 PM
JUnit test case relative to codegen/src/test.

Werner Guttmann - 18/Mar/08 06:24 PM
As a workaround, please set the following property in a custom castor.properties as follows:
# Property specifying whether sequence order validation should be lenient;
# Defaults to false
#
org.exolab.castor.xml.lenient.sequence.order=true

This turns off sequence validation.


Ronald R. DiFrango - 19/Mar/08 12:16 PM
I added the above to a file called castor.properties and now I am getting the following exception:

org.exolab.castor.xml.MarshalException: The following exception occured while validating field: _responseTypeSequence of class: xml.template.gen.CreditApplicationResponse: The field '_applicationKey' (whose xml name is 'ApplicationKey') is a required field of class 'xml.template.gen.ResponseTypeSequence{File: [not available]; line: 8; column: 29}
at org.exolab.castor.xml.Unmarshaller.convertSAXExceptionToMarshalException(Unmarshaller.java:761)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:727)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:616)
at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:807)
at xml.template.gen.CreditApplicationResponse.unmarshal(CreditApplicationResponse.java:103)
at xml.template.TestTemplate.testUnmarshalEntity(TestTemplate.java:31)
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:164)
at junit.framework.TestCase.runBare(TestCase.java:130)
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:120)
at junit.framework.TestSuite.runTest(TestSuite.java:230)
at junit.framework.TestSuite.run(TestSuite.java:225)
at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
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: The following exception occured while validating field: _responseTypeSequence of class: xml.template.gen.CreditApplicationResponse: The field '_applicationKey' (whose xml name is 'ApplicationKey') is a required field of class 'xml.template.gen.ResponseTypeSequence;

  • location of error: XPATH: /CreditApplicationResponse
    The field '_applicationKey' (whose xml name is 'ApplicationKey') is a required field of class 'xml.template.gen.ResponseTypeSequence
    at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:278)
    at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:1010)
    at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:910)
    at org.exolab.castor.xml.Validator.validate(Validator.java:135)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:915)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:686)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:686)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:1159)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(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.XML11Configuration.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:715)
    ... 22 more
    Caused by: ValidationException: The field '_applicationKey' (whose xml name is 'ApplicationKey') is a required field of class 'xml.template.gen.ResponseTypeSequence;
  • location of error: XPATH:
    at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:210)
    at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:1065)
    at org.exolab.castor.xml.Validator.validate(Validator.java:135)
    at org.exolab.castor.xml.FieldValidator.validateInstance(FieldValidator.java:326)
    at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:271)
    ... 38 more
    Caused by: ValidationException: The following exception occured while validating field: _responseTypeSequence of class: xml.template.gen.CreditApplicationResponse: The field '_applicationKey' (whose xml name is 'ApplicationKey') is a required field of class 'xml.template.gen.ResponseTypeSequence;
  • location of error: XPATH: /CreditApplicationResponse
    The field '_applicationKey' (whose xml name is 'ApplicationKey') is a required field of class 'xml.template.gen.ResponseTypeSequence
    at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:278)
    at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:1010)
    at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:910)
    at org.exolab.castor.xml.Validator.validate(Validator.java:135)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:915)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:686)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:686)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:1159)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(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.XML11Configuration.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:715)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:616)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:807)
    at xml.template.gen.CreditApplicationResponse.unmarshal(CreditApplicationResponse.java:103)
    at xml.template.TestTemplate.testUnmarshalEntity(TestTemplate.java:31)
    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:164)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    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:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:230)
    at junit.framework.TestSuite.run(TestSuite.java:225)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    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: The field '_applicationKey' (whose xml name is 'ApplicationKey') is a required field of class 'xml.template.gen.ResponseTypeSequence;
  • location of error: XPATH:
    at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:210)
    at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:1065)
    at org.exolab.castor.xml.Validator.validate(Validator.java:135)
    at org.exolab.castor.xml.FieldValidator.validateInstance(FieldValidator.java:326)
    at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:271)
    ... 38 more
    Caused by: ValidationException: The field '_applicationKey' (whose xml name is 'ApplicationKey') is a required field of class 'xml.template.gen.ResponseTypeSequence;
  • location of error: XPATH:
    at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:210)
    at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:1065)
    at org.exolab.castor.xml.Validator.validate(Validator.java:135)
    at org.exolab.castor.xml.FieldValidator.validateInstance(FieldValidator.java:326)
    at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:271)
    at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:1010)
    at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:910)
    at org.exolab.castor.xml.Validator.validate(Validator.java:135)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:915)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:686)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:686)
    at org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:1159)
    at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(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.XML11Configuration.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:715)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:616)
    at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:807)
    at xml.template.gen.CreditApplicationResponse.unmarshal(CreditApplicationResponse.java:103)
    at xml.template.TestTemplate.testUnmarshalEntity(TestTemplate.java:31)
    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:164)
    at junit.framework.TestCase.runBare(TestCase.java:130)
    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:120)
    at junit.framework.TestSuite.runTest(TestSuite.java:230)
    at junit.framework.TestSuite.run(TestSuite.java:225)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
    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 put castor.properties at the root level of my src/classes folder. I also tried re-generating the code with this option turned on and I got the same error.


Ronald R. DiFrango - 19/Mar/08 12:18 PM
This is my castor.properties file.

Ronald R. DiFrango - 19/Mar/08 12:20 PM
And here is my castorbuild.properties file that I used to compile the schema.

Werner Guttmann - 20/Mar/08 08:26 AM
Hmm .. looks like there's a more serious problem. In case you are using XML parser validation to validate against an XML schema, you can always turn off validation completely, by setting
# True if all documents should be validated by the marshaling framework
# Defaults to true.
#
org.exolab.castor.marshalling.validation=false

in your castor.properties file. But that will turn off (object-level) validation completely. But it might be a work-around for you.


Werner Guttmann - 24/Jun/08 06:35 AM
Ronald, can I (safely) assume that this is till an issue for you ?

Ronald R. DiFrango - 24/Jun/08 07:12 AM
Werner, yes this still is an issue for me. It "works" OK if I turn off validation, but I would prefer to not do that if I could. So fixing this would be great.