You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tuscany.apache.org by "Fuhwei Lwo (JIRA)" <tu...@ws.apache.org> on 2007/02/22 16:46:06 UTC

[jira] Commented: (TUSCANY-1132) SDO Java serialization/deserialization throws an exception when the serialized data object is not the root and its container is of AnyTypeDataObject

    [ https://issues.apache.org/jira/browse/TUSCANY-1132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12475050 ] 

Fuhwei Lwo commented on TUSCANY-1132:
-------------------------------------

I found out the problem was caused by the HelperProviderImpl.writeDataObject() method that cannot handle the serialized data object that has a container.  I made a quick fix in the writeExternal() method and my test case works. Now, the question is whether this fix is good enough by making a new copy of dataobject tree or we should take the similar approach like XMLDocumentImpl.save() to preserve the original dataobjec tree by temporarily detach the target, serialize it, then put it back.

public void writeExternal(ObjectOutput out) throws IOException
    {
      if (target instanceof DataObject)
      {
          if(out instanceof SDOObjectOutputStream)
          {
              CopyHelper copyHelperLocal = ((SDOObjectOutputStream)out).getHelperContext().getCopyHelper();
              target = copyHelperLocal.copy((DataObject)target);
          }
        writeDataObject((DataObject)target, out);
      }
      else
      {
        throw new NotSerializableException(); // should never happen
      }
    }

> 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 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@65786578 (eClass: org.apache.tuscany.sdo.impl.ClassImpl@c380c38 (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 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@65786578 (eClass: org.apache.tuscany.sdo.impl.ClassImpl@c380c38 (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: tuscany-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-dev-help@ws.apache.org