Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » serialization(java.lang.ClassCastException)
serialization [message #666688] Thu, 21 April 2011 16:06 Go to next message
ben  is currently offline ben Friend
Messages: 30
Registered: April 2011
Location: France/Bordeaux
Member
Hi
I'm trying to seriliaze a model of my system.

That's is a small part of my code.

((List) BicObject.eGet(ref)).add(arrayencreObject);

BicObject is an instance of my EClass EClassBic
arrayencreObject is an EObject array from an instance of my EClass EClassEncre like :


EObject[] arrayencreObject = new EObject ;

for (int i=0;i<9;i++) {

arrayencreObject[i] = EcoreUtil.create(encreEClass);
}
EClassEncre is contains into EClassBic through a reference ref.

when i trying to serialize this model, i have this exception.


java.lang.ClassCastException: [Lorg.eclipse.emf.ecore.EObject; cannot be cast to org.eclipse.emf.ecore.InternalEObject
at org.eclipse.emf.ecore.util.EcoreEList.inverseAdd(EcoreEList. java:267)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq ue(NotifyingListImpl.java:318)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList. java:307)
at dynamic.model.dynamicDataModel.creatModelPackage(dynamicData Model.java:665)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall( FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(Refl ectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(Fr ameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate( InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit 4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit 4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java: 52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java :191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java: 42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java: 184)
at org.junit.internal.runners.statements.RunBefores.evaluate(Ru nBefores.java:28)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test Execution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:390)
at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunne r.main(RemotePluginTestRunner.java:62)
at org.eclipse.pde.internal.junit.runtime.UITestApplication$1.r un(UITestApplication.java:116)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:4041)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3660)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 38)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:115)
at org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:47)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

someone can help me please or give some idea.
Thank you in advance.


Re: serialization [message #666699 is a reply to message #666688] Thu, 21 April 2011 16:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Ben,

Comments below.

ben wrote:
> Hi
> I'm trying to seriliaze a model of my system.
>
> That's is a small part of my code.
>
> ((List) BicObject.eGet(ref)).add(arrayencreObject);
>
> BicObject is an instance of my EClass EClassBic
> arrayencreObject is an EObject array from an instance of my EClass
> EClassEncre like :
>
> EObject[] arrayencreObject = new EObject ;
Something missing here?
>
> for (int i=0;i<9;i++) {
>
> arrayencreObject[i] = EcoreUtil.create(encreEClass);
> }
> EClassEncre is contains into EClassBic through a reference ref.
>
> when i trying to serialize this model, i have this exception.
>
>
> java.lang.ClassCastException: [Lorg.eclipse.emf.ecore.EObject; cannot
> be cast to org.eclipse.emf.ecore.InternalEObject
I think there's something you've not explained. You're adding an array
of EObjects somewhere that expects and EObject?
> at org.eclipse.emf.ecore.util.EcoreEList.inverseAdd(EcoreEList.
> java:267)
> at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUniq
> ue(NotifyingListImpl.java:318)
> at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.
> java:307)
> at dynamic.model.dynamicDataModel.creatModelPackage(dynamicData
> Model.java:665)
What's at this line?
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
> FrameworkMethod.java:44)
> at org.junit.internal.runners.model.ReflectiveCallable.run(Refl
> ectiveCallable.java:15)
> at org.junit.runners.model.FrameworkMethod.invokeExplosively(Fr
> ameworkMethod.java:41)
> at org.junit.internal.runners.statements.InvokeMethod.evaluate(
> InvokeMethod.java:20)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit
> 4ClassRunner.java:76)
> at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit
> 4ClassRunner.java:50)
> at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
> at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java: 52)
> at org.junit.runners.ParentRunner.runChildren(ParentRunner.java
> :191)
> at org.junit.runners.ParentRunner.access$000(ParentRunner.java: 42)
> at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java: 184)
> at org.junit.internal.runners.statements.RunBefores.evaluate(Ru
> nBefores.java:28)
> at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
> at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r
> un(JUnit4TestReference.java:49)
> at org.eclipse.jdt.internal.junit.runner.TestExecution.run(Test
> Execution.java:38)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe
> sts(RemoteTestRunner.java:467)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe
> sts(RemoteTestRunner.java:683)
> at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R
> emoteTestRunner.java:390)
> at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunne
> r.main(RemotePluginTestRunner.java:62)
> at org.eclipse.pde.internal.junit.runtime.UITestApplication$1.r
> un(UITestApplication.java:116)
> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
> at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr
> onizer.java:134)
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav
> a:4041)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
> :3660)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav
> a:2640)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 38)
> at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
> at org.eclipse.core.databinding.observable.Realm.runWithDefault
> (Realm.java:332)
> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work
> bench.java:664)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j
> ava:149)
> at org.eclipse.ui.internal.ide.application.IDEApplication.start
> (IDEApplication.java:115)
> at org.eclipse.pde.internal.junit.runtime.UITestApplication.sta
> rt(UITestApplication.java:47)
> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips
> eAppHandle.java:196)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
> .runApplication(EclipseAppLauncher.java:110)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
> .start(EclipseAppLauncher.java:79)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS
> tarter.java:369)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS
> tarter.java:179)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
>
> someone can help me please or give some idea.
> Thank you in advance.
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: serialization [message #666752 is a reply to message #666699] Fri, 22 April 2011 07:55 Go to previous message
ben  is currently offline ben Friend
Messages: 30
Registered: April 2011
Location: France/Bordeaux
Member
Ed,

Comments below.

Ed wrote:
< EObject[] arrayencreObject = new EObject ;
<Something missing here?

What ?

<I think there's something you've not explained. You're adding an <array of EObjects somewhere that expects and EObject?

yes , you are right, vi want to add an array of EObjects to EObject.
BicObject ----> an EObject
arrayencreObject ----> an array of EObjects.
i don't know if it is possible but i have to do.

<at dynamic.model.dynamicDataModel.creatModelPackage
<(dynamicData
< Model.java:665)
<What's at this line?

dynamic.model---> Package
dynamicDataModel-->my file include in dynamic.model
creatModelPackage---> methods where i built my model.

It is possible to add an array of EObject to a simple EObject when i serialize my model ?
Thank you in advance.

cheers
ben



Previous Topic:[Teneo] Containment in superclass causes foreign key issues using TABLE_PER_CLASS
Next Topic:[CDO] HibernateStore - What is the recommended version for getting started?
Goto Forum:
  


Current Time: Fri Apr 26 03:25:27 GMT 2024

Powered by FUDForum. Page generated in 0.03023 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top