[
https://issues.apache.org/jira/browse/TUSCANY-1132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475146
]
Fuhwei Lwo commented on TUSCANY-1132:
-------------------------------------
Let me try with some code.
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos = SDOUtil.createObjectOutputStream(bos, hc);
oos.writeObject(nonRootDataObject); // <=== code to pay attention
oos.close();
bos.close();
When the client code above was executed, the writeDataObject(DataObject,
ObjectOutput) method in the HelperProviderImpl will be called for every
dataobject in the tree. In the writeDataObject(), there is a condition like
below to serialize the dataobject with xpath starting from the root dataobject.
Since the client code above is trying to serialize the nonRootDataObject not
the root object, the xpath will be wrong when readObject() was called later.
else if (dataObject.getContainer() != null)
{
objectOutput.writeByte(0);
objectOutput.writeUTF(DataObjectUtil.getXPath(dataObject));
objectOutput.writeObject(dataObject.getRootObject());
}
Let me know if you have further question.
> SDO Java serialization/deserialization throws an exception when the
> serialized data object is not the root and its container is of
> AnyTypeDataObject
> ----------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: TUSCANY-1132
> URL: https://issues.apache.org/jira/browse/TUSCANY-1132
> Project: Tuscany
> Issue Type: Bug
> Components: Java SDO Implementation
> Affects Versions: Java-SDO-M3
> Reporter: Fuhwei Lwo
> Fix For: Java-SDO-M3
>
> Attachments: tuscany-1132-testcase.patch
>
>
> With or without the patch of TUSCANY-1131 to fix the problem in
> XMLDocumentImpl.java, this problem always exists. With the fix from
> TUSCANY-1131, now I got this exception. I believe there are still some
> problem in the SDO Java serialization/deserialization code.
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Value '[EMAIL
> PROTECTED] (eClass: [EMAIL PROTECTED] (name: DataObject) (instanceClassName:
> null) (abstract: true, interface: false))' is not legal. (http:///temp.xml,
> 3, 50)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:80)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:275)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:666)
> at
> org.apache.tuscany.sdo.util.resource.SDOXMLResourceImpl.doLoad(SDOXMLResourceImpl.java:463)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.load(XMLResourceImpl.java:634)
> at
> org.apache.tuscany.sdo.helper.XMLDocumentImpl.load(XMLDocumentImpl.java:246)
> at
> org.apache.tuscany.sdo.helper.XMLDocumentImpl.load(XMLDocumentImpl.java:224)
> at
> org.apache.tuscany.sdo.helper.XMLHelperImpl.load(XMLHelperImpl.java:78)
> at
> org.apache.tuscany.sdo.helper.XMLHelperImpl.load(XMLHelperImpl.java:72)
> at
> org.apache.tuscany.sdo.helper.HelperProviderImpl$ResolvableImpl.readDataObject(HelperProviderImpl.java:210)
> at
> org.apache.tuscany.sdo.helper.HelperProviderImpl$ResolvableImpl.readExternal(HelperProviderImpl.java:150)
> at
> commonj.sdo.impl.ExternalizableDelegator.readExternal(ExternalizableDelegator.java:83)
> at
> java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1774)
> at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1736)
> at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1324)
> at java.io.ObjectInputStream.readObject(ObjectInputStream.java:362)
> at
> org.apache.tuscany.sdo.helper.HelperProviderImpl$ResolvableImpl.readDataObject(HelperProviderImpl.java:219)
> at
> org.apache.tuscany.sdo.helper.HelperProviderImpl$ResolvableImpl.readExternal(HelperProviderImpl.java:150)
> at
> commonj.sdo.impl.ExternalizableDelegator.readExternal(ExternalizableDelegator.java:83)
> at
> java.io.ObjectInputStream.readExternalData(ObjectInputStream.java:1774)
> at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1736)
> at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1324)
> at java.io.ObjectInputStream.readObject(ObjectInputStream.java:362)
> at
> org.apache.tuscany.sdo.test.JavaSerializeDeserializeTestCase.testAnyTypeContainer(JavaSerializeDeserializeTestCase.java:70)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:615)
> 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: org.eclipse.emf.ecore.xmi.IllegalValueException: Value '[EMAIL
> PROTECTED] (eClass: [EMAIL PROTECTED] (name: DataObject) (instanceClassName:
> null) (abstract: true, interface: false))' is not legal. (http:///temp.xml,
> 3, 50)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2418)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2403)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFeatureType(XMLHandler.java:1920)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:1788)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1566)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createDocumentRoot(XMLHandler.java:1234)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1162)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1244)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:880)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:863)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:627)
> at
> org.apache.tuscany.sdo.util.resource.SDOXMLResourceImpl$SDOXMLLoadImpl$XmlHandler.startElement(SDOXMLResourceImpl.java:289)
> at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(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.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:265)
> ... 40 more
> Caused by: java.lang.ClassCastException: The feature 'dataObject's type
> 'DataObject' does not permit a value of type 'DataObject'
> at
> org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$BasicFeatureMapEntry.validate(EStructuralFeatureImpl.java:2843)
> at
> org.eclipse.emf.ecore.util.FeatureMapUtil.createEntry(FeatureMapUtil.java:146)
> at
> org.eclipse.emf.ecore.util.BasicFeatureMap.createEntry(BasicFeatureMap.java:94)
> at
> org.eclipse.emf.ecore.util.BasicFeatureMap.set(BasicFeatureMap.java:1051)
> at
> org.eclipse.emf.ecore.util.FeatureMapUtil$FeatureValue.set(FeatureMapUtil.java:1150)
> at
> org.eclipse.emf.ecore.impl.EStructuralFeatureImpl$InternalSettingDelegateFeatureMapDelegator.dynamicSet(EStructuralFeatureImpl.java:1401)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl.java:709)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:683)
> at
> org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:654)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1091)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2413)
> ... 62 more
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]