Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [CDO] DanglingHREFException after putEPackage()
[CDO] DanglingHREFException after putEPackage() [message #114899] Mon, 17 March 2008 09:31 Go to next message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 307
Registered: July 2009
Location: Germany
Senior Member
Hi Eike,

I'm running into the exception mentioned above. I'm not sure if this is
a bug or if I have to modify my generator model(s).
Here's the setting:

I have two packages and a class in each one - I'll use a textual
notation to illustrate the EMF-Models:

package base {
class BaseClass {
attribute counter : EInt;
operation increment() : void;
}
}

package derived {
class DerivedClass extends base.BaseClass {
operation decrement() : void;
}
}


Package base is defined in base.ecore and base.genmodel. Package derived
is defined likewise in derived.ecore and derived.genmodel, which refers
to base.genmodel. Models validate correctly and model code is generated
as it should.

(This is only an example which I extracted from my code, what I really
want is a package declaring a set of interfaces which classes in other
packages can implement, but the above is the code I used to reproduce
the problem, I can send you the test code if you need it).

Now, what I'm doing is simply creating a container, repository,
transaction, resource etc. and then:

session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);


The first call succeeds, the second one throws an exception:

org.eclipse.net4j.util.io.IORuntimeException: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name: BaseClass) (instanceClassName: null) (abstract: false, interface: false)' is not contained in a resource.
at org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
at org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
at org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
at org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
at org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
at test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
at org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
at org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
at org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
at org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
at org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
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:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
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:118)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
at org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
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: 564)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
Caused by: org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name: BaseClass) (instanceClassName: null) (abstract: false, interface: false)' is not contained in a resource.
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
at org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
... 52 more
Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name: BaseClass) (instanceClassName: null) (abstract: false, interface: false)' is not contained in a resource.
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
... 55 more

So, is this a bug and CDO has Problems handling referenced packages, or
do I have to modify something in my models or code?

(BTW, I updated to HEAD last Thrusday before testing this...)

Cheers,
Stefan
Re: [CDO] DanglingHREFException after putEPackage() [message #114912 is a reply to message #114899] Mon, 17 March 2008 12:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

Hi Stefan,

This is clearly a bug in CDO. Fortunately it is really minor since it occurs only when you add more than one package in one transaction (commit). If you add them one by one everything should be fine. Background: CDO converts the EPackages into CDOPackages and uses the latter subsequently. In addition the EPackages are converted to XML strings and stored in the backaend, just in case a client does not have the generated Jva code at hand. Then the XML string would be deserialized to the client so that it can use a dynamic model. Also the new Hibernate integration will use this string on the server side to get access to the mapping annotations.

Can you please file a Bugzilla so that we can track the progress of the fix?

Greeting from the EclipseCon ;-)
/Eike



Stefan Winkler schrieb:
> Hi Eike,
>
> I'm running into the exception mentioned above. I'm not sure if this is
> a bug or if I have to modify my generator model(s).
> Here's the setting:
>
> I have two packages and a class in each one - I'll use a textual
> notation to illustrate the EMF-Models:
>
> package base {
> class BaseClass {
> attribute counter : EInt;
> operation increment() : void;
> }
> }
>
> package derived {
> class DerivedClass extends base.BaseClass {
> operation decrement() : void;
> }
> }
>
>
> Package base is defined in base.ecore and base.genmodel. Package derived
> is defined likewise in derived.ecore and derived.genmodel, which refers
> to base.genmodel. Models validate correctly and model code is generated
> as it should.
>
> (This is only an example which I extracted from my code, what I really
> want is a package declaring a set of interfaces which classes in other
> packages can implement, but the above is the code I used to reproduce
> the problem, I can send you the test code if you need it).
>
> Now, what I'm doing is simply creating a container, repository,
> transaction, resource etc. and then:
>
> session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
> session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);
>
>
> The first call succeeds, the second one throws an exception:
>
> org.eclipse.net4j.util.io.IORuntimeException:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The object
> 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name: BaseClass)
> (instanceClassName: null) (abstract: false, interface: false)' is not
> contained in a resource.
> at org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
> at
> org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
>
> at
> org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
>
> at
> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
>
> at
> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
>
> at test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
> 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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
>
> at
> org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
>
> at
> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>
> at
> org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
>
> at
> org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
> at
> org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
>
> at
> org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
>
> at
> org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
>
> at
> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>
> at
> org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>
> 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:460)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>
> 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:118)
>
> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
> at
> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
>
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>
> at
> org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
>
> 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: 564)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
> Caused by: org.eclipse.emf.ecore.resource.Resource$IOWrappedException:
> The object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
> BaseClass) (instanceClassName: null) (abstract: false, interface:
> false)' is not contained in a resource.
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
>
> at org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
> ... 52 more
> Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The object
> 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name: BaseClass)
> (instanceClassName: null) (abstract: false, interface: false)' is not
> contained in a resource.
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
> ... 55 more
>
> So, is this a bug and CDO has Problems handling referenced packages, or
> do I have to modify something in my models or code?
>
> (BTW, I updated to HEAD last Thrusday before testing this...)
>
> Cheers,
> Stefan
Re: [CDO] DanglingHREFException after putEPackage() [message #114927 is a reply to message #114912] Mon, 17 March 2008 16:07 Go to previous messageGo to next message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 307
Registered: July 2009
Location: Germany
Senior Member
This is a multi-part message in MIME format.
--------------000309050507020903050007
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi Eike,

Comments below ...

Eike Stepper schrieb:
> Hi Stefan,
>
> This is clearly a bug in CDO. Fortunately it is really minor since it
> occurs only when you add more than one package in one transaction
> (commit). If you add them one by one everything should be fine.
No, it doesn't :-( - maybe because the PackageManager is part of the
session and not the transaction?

I included my testcase as a Bug attachment.
> Background: CDO converts the EPackages into CDOPackages and uses the
> latter subsequently. In addition the EPackages are converted to XML
> strings and stored in the backaend, just in case a client does not
> have the generated Jva code at hand. Then the XML string would be
> deserialized to the client so that it can use a dynamic model. Also
> the new Hibernate integration will use this string on the server side
> to get access to the mapping annotations.
>
> Can you please file a Bugzilla so that we can track the progress of
> the fix?
-> Bug 222974 <https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974>
> Greeting from the EclipseCon ;-)
Oh right, I forgot about the Con ;-) Have fun in California (and do go
shopping, it really pays right now *g*).

Cheers,
Stefan


> /Eike
>
>
>
> Stefan Winkler schrieb:
>> Hi Eike,
>>
>> I'm running into the exception mentioned above. I'm not sure if this
>> is a bug or if I have to modify my generator model(s).
>> Here's the setting:
>>
>> I have two packages and a class in each one - I'll use a textual
>> notation to illustrate the EMF-Models:
>>
>> package base {
>> class BaseClass {
>> attribute counter : EInt;
>> operation increment() : void;
>> }
>> }
>>
>> package derived {
>> class DerivedClass extends base.BaseClass {
>> operation decrement() : void;
>> }
>> }
>>
>>
>> Package base is defined in base.ecore and base.genmodel. Package
>> derived is defined likewise in derived.ecore and derived.genmodel,
>> which refers to base.genmodel. Models validate correctly and model
>> code is generated as it should.
>>
>> (This is only an example which I extracted from my code, what I
>> really want is a package declaring a set of interfaces which classes
>> in other packages can implement, but the above is the code I used to
>> reproduce the problem, I can send you the test code if you need it).
>>
>> Now, what I'm doing is simply creating a container, repository,
>> transaction, resource etc. and then:
>>
>> session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
>> session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);
>>
>>
>> The first call succeeds, the second one throws an exception:
>>
>> org.eclipse.net4j.util.io.IORuntimeException:
>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>> false)' is not contained in a resource.
>> at
>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
>> at
>> org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
>>
>> at
>> org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
>>
>> at
>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
>>
>> at
>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
>>
>> at
>> test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
>> 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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
>>
>> at
>> org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
>>
>> at
>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>
>> at
>> org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
>>
>> at
>> org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
>>
>> at
>> org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
>>
>> at
>> org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
>>
>> at
>> org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
>>
>> at
>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>
>> at
>> org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
>> at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>>
>> 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:460)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>
>> 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:118)
>>
>> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
>> at
>> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
>>
>> at
>> org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
>> at
>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
>> at
>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
>> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
>> at
>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>
>> at
>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
>>
>> at
>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>> at
>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>>
>> at
>> org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
>>
>> at
>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>
>> at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>>
>> at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
>>
>> 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: 564)
>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>> at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
>> at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
>> Caused by:
>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>> false)' is not contained in a resource.
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
>>
>> at
>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
>> ... 52 more
>> Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The
>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>> false)' is not contained in a resource.
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
>> ... 55 more
>>
>> So, is this a bug and CDO has Problems handling referenced packages,
>> or do I have to modify something in my models or code?
>>
>> (BTW, I updated to HEAD last Thrusday before testing this...)
>>
>> Cheers,
>> Stefan

--------------000309050507020903050007
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Eike,<br>
<br>
Comments below ...<br>
<br>
Eike Stepper schrieb:
<blockquote cite="mid:frlovc$fs3$1@build.eclipse.org" type="cite">Hi
Stefan,
<br>
<br>
This is clearly a bug in CDO. Fortunately it is really minor since it
occurs only when you add more than one package in one transaction
(commit). If you add them one by one everything should be fine. </blockquote>
No, it doesn't :-( - maybe because the PackageManager is part of the
session and not the transaction?<br>
<br>
I included my testcase as a Bug attachment.<br>
<blockquote cite="mid:frlovc$fs3$1@build.eclipse.org" type="cite">Background:
CDO converts the EPackages into CDOPackages and uses the latter
subsequently. In addition the EPackages are converted to XML strings
and stored in the backaend, just in case a client does not have the
generated Jva code at hand. Then the XML string would be deserialized
to the client so that it can use a dynamic model. Also the new
Hibernate integration will use this string on the server side to get
access to the mapping annotations.
<br>
<br>
Can you please file a Bugzilla so that we can track the progress of the
fix?
<br>
</blockquote>
-&gt; <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974"
title="NEW - [CDO] DanglingHREFException after putEPackage() when using referencing models">Bug
222974</a>
<blockquote cite="mid:frlovc$fs3$1@build.eclipse.org" type="cite">Greeting
from the EclipseCon ;-)
<br>
</blockquote>
Oh right, I forgot about the Con ;-) Have fun in California (and do go
shopping, it really pays right now *g*).<br>
<br>
Cheers,<br>
Stefan<br>
<br>
<br>
<blockquote cite="mid:frlovc$fs3$1@build.eclipse.org" type="cite">/Eike
<br>
<br>
<br>
<br>
Stefan Winkler schrieb:
<br>
<blockquote type="cite">Hi Eike,
<br>
<br>
I'm running into the exception mentioned above. I'm not sure if this is
a bug or if I have to modify my generator model(s).
<br>
Here's the setting:
<br>
<br>
I have two packages and a class in each one - I'll use a textual
notation to illustrate the EMF-Models:
<br>
<br>
package base {
<br>
Re: [CDO] DanglingHREFException after putEPackage() [message #114971 is a reply to message #114927] Mon, 17 March 2008 18:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

Hi Stefan,

I already worked a bit on a fix. But my time is a bit limited due to all the interesting people and talks here at the EclipseCon ;-) I'l keep you informed...

Cheers
/Eike



Stefan Winkler schrieb:
> Hi Eike,
>
> Comments below ...
>
> Eike Stepper schrieb:
>> Hi Stefan,
>>
>> This is clearly a bug in CDO. Fortunately it is really minor since it
>> occurs only when you add more than one package in one transaction
>> (commit). If you add them one by one everything should be fine.
> No, it doesn't :-( - maybe because the PackageManager is part of the
> session and not the transaction?
>
> I included my testcase as a Bug attachment.
>> Background: CDO converts the EPackages into CDOPackages and uses the
>> latter subsequently. In addition the EPackages are converted to XML
>> strings and stored in the backaend, just in case a client does not
>> have the generated Jva code at hand. Then the XML string would be
>> deserialized to the client so that it can use a dynamic model. Also
>> the new Hibernate integration will use this string on the server side
>> to get access to the mapping annotations.
>>
>> Can you please file a Bugzilla so that we can track the progress of
>> the fix?
> -> Bug 222974 <https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974>
>> Greeting from the EclipseCon ;-)
> Oh right, I forgot about the Con ;-) Have fun in California (and do go
> shopping, it really pays right now *g*).
>
> Cheers,
> Stefan
>
>
>> /Eike
>>
>>
>>
>> Stefan Winkler schrieb:
>>> Hi Eike,
>>>
>>> I'm running into the exception mentioned above. I'm not sure if this
>>> is a bug or if I have to modify my generator model(s).
>>> Here's the setting:
>>>
>>> I have two packages and a class in each one - I'll use a textual
>>> notation to illustrate the EMF-Models:
>>>
>>> package base {
>>> class BaseClass {
>>> attribute counter : EInt;
>>> operation increment() : void;
>>> }
>>> }
>>>
>>> package derived {
>>> class DerivedClass extends base.BaseClass {
>>> operation decrement() : void;
>>> }
>>> }
>>>
>>>
>>> Package base is defined in base.ecore and base.genmodel. Package
>>> derived is defined likewise in derived.ecore and derived.genmodel,
>>> which refers to base.genmodel. Models validate correctly and model
>>> code is generated as it should.
>>>
>>> (This is only an example which I extracted from my code, what I
>>> really want is a package declaring a set of interfaces which classes
>>> in other packages can implement, but the above is the code I used to
>>> reproduce the problem, I can send you the test code if you need it).
>>>
>>> Now, what I'm doing is simply creating a container, repository,
>>> transaction, resource etc. and then:
>>>
>>> session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
>>> session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);
>>>
>>>
>>> The first call succeeds, the second one throws an exception:
>>>
>>> org.eclipse.net4j.util.io.IORuntimeException:
>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>> false)' is not contained in a resource.
>>> at
>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
>>> at
>>> org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
>>>
>>> at
>>> org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
>>>
>>> at
>>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
>>>
>>> at
>>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
>>>
>>> at
>>> test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
>>> 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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
>>>
>>> at
>>> org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
>>>
>>> at
>>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>
>>> at
>>> org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
>>>
>>> at
>>> org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
>>>
>>> at
>>> org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
>>>
>>> at
>>> org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
>>>
>>> at
>>> org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
>>>
>>> at
>>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>
>>> at
>>> org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
>>> at
>>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>>>
>>> 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:460)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>
>>> 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:118)
>>>
>>> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
>>> at
>>> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
>>>
>>> at
>>> org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
>>> at
>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
>>> at
>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
>>> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
>>> at
>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>
>>> at
>>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
>>>
>>> at
>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>> at
>>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>>>
>>> at
>>> org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
>>>
>>> at
>>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>
>>> at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>>>
>>> at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>>>
>>> at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
>>>
>>> at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
>>>
>>> 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: 564)
>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
>>> Caused by:
>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>> false)' is not contained in a resource.
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
>>>
>>> at
>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
>>> ... 52 more
>>> Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The
>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>> false)' is not contained in a resource.
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
>>> ... 55 more
>>>
>>> So, is this a bug and CDO has Problems handling referenced packages,
>>> or do I have to modify something in my models or code?
>>>
>>> (BTW, I updated to HEAD last Thrusday before testing this...)
>>>
>>> Cheers,
>>> Stefan
Re: [CDO] DanglingHREFException after putEPackage() [message #115009 is a reply to message #114927] Mon, 17 March 2008 18:45 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: stepper.sympedia.de

Stefan Winkler schrieb:
> Hi Eike,
>
> Comments below ...
>
> Eike Stepper schrieb:
>> Hi Stefan,
>>
>> This is clearly a bug in CDO. Fortunately it is really minor since it
>> occurs only when you add more than one package in one transaction
>> (commit). If you add them one by one everything should be fine.
> No, it doesn't :-( - maybe because the PackageManager is part of the
> session and not the transaction?
>
> I included my testcase as a Bug attachment.

I'll work on it later on...

>> Background: CDO converts the EPackages into CDOPackages and uses the
>> latter subsequently. In addition the EPackages are converted to XML
>> strings and stored in the backaend, just in case a client does not
>> have the generated Jva code at hand. Then the XML string would be
>> deserialized to the client so that it can use a dynamic model. Also
>> the new Hibernate integration will use this string on the server side
>> to get access to the mapping annotations.
>>
>> Can you please file a Bugzilla so that we can track the progress of
>> the fix?
> -> Bug 222974 <https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974>
>> Greeting from the EclipseCon ;-)
> Oh right, I forgot about the Con ;-) Have fun in California (and do go
> shopping, it really pays right now *g*).

Oh, yeah! But I've been in New York in January and there's simply no more space available in our wardrobe ;-)

Cheers
/Eike


>
> Cheers,
> Stefan
>
>
>> /Eike
>>
>>
>>
>> Stefan Winkler schrieb:
>>> Hi Eike,
>>>
>>> I'm running into the exception mentioned above. I'm not sure if this
>>> is a bug or if I have to modify my generator model(s).
>>> Here's the setting:
>>>
>>> I have two packages and a class in each one - I'll use a textual
>>> notation to illustrate the EMF-Models:
>>>
>>> package base {
>>> class BaseClass {
>>> attribute counter : EInt;
>>> operation increment() : void;
>>> }
>>> }
>>>
>>> package derived {
>>> class DerivedClass extends base.BaseClass {
>>> operation decrement() : void;
>>> }
>>> }
>>>
>>>
>>> Package base is defined in base.ecore and base.genmodel. Package
>>> derived is defined likewise in derived.ecore and derived.genmodel,
>>> which refers to base.genmodel. Models validate correctly and model
>>> code is generated as it should.
>>>
>>> (This is only an example which I extracted from my code, what I
>>> really want is a package declaring a set of interfaces which classes
>>> in other packages can implement, but the above is the code I used to
>>> reproduce the problem, I can send you the test code if you need it).
>>>
>>> Now, what I'm doing is simply creating a container, repository,
>>> transaction, resource etc. and then:
>>>
>>> session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
>>> session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);
>>>
>>>
>>> The first call succeeds, the second one throws an exception:
>>>
>>> org.eclipse.net4j.util.io.IORuntimeException:
>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>> false)' is not contained in a resource.
>>> at
>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
>>> at
>>> org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
>>>
>>> at
>>> org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
>>>
>>> at
>>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
>>>
>>> at
>>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
>>>
>>> at
>>> test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
>>> 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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
>>>
>>> at
>>> org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
>>>
>>> at
>>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>
>>> at
>>> org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
>>>
>>> at
>>> org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
>>>
>>> at
>>> org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
>>>
>>> at
>>> org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
>>>
>>> at
>>> org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
>>>
>>> at
>>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>
>>> at
>>> org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
>>> at
>>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>>>
>>> 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:460)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>
>>> 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:118)
>>>
>>> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
>>> at
>>> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
>>>
>>> at
>>> org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
>>> at
>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
>>> at
>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
>>> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
>>> at
>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>
>>> at
>>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
>>>
>>> at
>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>> at
>>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>>>
>>> at
>>> org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
>>>
>>> at
>>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>
>>> at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>>>
>>> at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>>>
>>> at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
>>>
>>> at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
>>>
>>> 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: 564)
>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
>>> Caused by:
>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>> false)' is not contained in a resource.
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
>>>
>>> at
>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
>>> ... 52 more
>>> Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The
>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>> false)' is not contained in a resource.
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
>>> ... 55 more
>>>
>>> So, is this a bug and CDO has Problems handling referenced packages,
>>> or do I have to modify something in my models or code?
>>>
>>> (BTW, I updated to HEAD last Thrusday before testing this...)
>>>
>>> Cheers,
>>> Stefan
Re: [CDO] DanglingHREFException after putEPackage() [message #116565 is a reply to message #114971] Wed, 02 April 2008 08:48 Go to previous messageGo to next message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 307
Registered: July 2009
Location: Germany
Senior Member
This is a multi-part message in MIME format.
--------------050407030807090701090105
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi Eike,

yesterday I updated to HEAD and tried my testcase and didn't catch an
exception. So I guess you fixed the bug?

Next, I tried to run my project again with the fixed registry, but again
ran into trouble.

What happens is this:

So what I do is as follows:
- I completely wipe the database (using the MySQL administrator, so it
is completely clean )
- I start my application. As part of the initialization process, my
application registers a bunch of packages (say A, B, C and D in that
order) - all goes well.
- I then create two objects - one of a class in package A and one of a
class in package C and commit my model.
- I exit the application.
- I start the application again. As part of the initialization process,
for every package, I try to figure out, if the package is already
registered and if not I register it.

I do this using the following code

|*private **void *registerPackage(EPackage pkg) {
*if *(trace) {
System.out.println("RequipseProjectPlugin.registerPackage("+ pkg.getNsURI() + ")");
}

CDOPackageRegistry packageRegistry = session.getPackageRegistry();
CDOPackageManager packageManager = session.getPackageManager();

CDOPackage existing = packageManager.lookupPackage(pkg.getNsURI());

*if*(existing == *null*) {
*try *{
packageRegistry.putEPackage(pkg);
*if *(trace) {
System.out.println(" ... done.");
}
}
*catch*(Exception e) {
logException(e);
}
}
*else if *(trace) {
System.out.println(" ... already exists.");
}
}
|


The result of this is as follows:
- The packages A and C (the ones I created the object with) are
recognized as already registered in the code above.
- The packages B and D are not recognized (|existing == null|).
- Consequently they are tried to be registered, but this leads to a

java.lang.ClassCastException:
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl$CDOPacka geDescriptor
cannot be cast to org.eclipse.emf.ecore.EPackage
at org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:271)
at
org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:163)
at
org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
at
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
at
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)

The problem is this:
- When the session is opened, the package registry seems to be populated
with CDOPackageRegistryImpl$CDOPackageDescriptor instances in
org.eclipse.emf.internal.cdo.CDOSessionPackageManagerImpl.
addPackageProxies(...)

- When I try to register an additional package,
org.eclipse.emf.cdo.util.EMFUtil.ePackageToString() iterates through the
registry and casts all elements to EObject, which leads to the exception
given above, because there still are
CDOPackageRegistryImpl$CDOPackageDescriptor instances in the registry.


Bug?

Cheers,
Stefan




Eike Stepper schrieb:
> Hi Stefan,
>
> I already worked a bit on a fix. But my time is a bit limited due to
> all the interesting people and talks here at the EclipseCon ;-) I'l
> keep you informed...
>
> Cheers
> /Eike
>
>
>
> Stefan Winkler schrieb:
>> Hi Eike,
>>
>> Comments below ...
>>
>> Eike Stepper schrieb:
>>> Hi Stefan,
>>>
>>> This is clearly a bug in CDO. Fortunately it is really minor since
>>> it occurs only when you add more than one package in one transaction
>>> (commit). If you add them one by one everything should be fine.
>> No, it doesn't :-( - maybe because the PackageManager is part of the
>> session and not the transaction?
>>
>> I included my testcase as a Bug attachment.
>>> Background: CDO converts the EPackages into CDOPackages and uses the
>>> latter subsequently. In addition the EPackages are converted to XML
>>> strings and stored in the backaend, just in case a client does not
>>> have the generated Jva code at hand. Then the XML string would be
>>> deserialized to the client so that it can use a dynamic model. Also
>>> the new Hibernate integration will use this string on the server
>>> side to get access to the mapping annotations.
>>>
>>> Can you please file a Bugzilla so that we can track the progress of
>>> the fix?
>> -> Bug 222974 <https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974>
>>> Greeting from the EclipseCon ;-)
>> Oh right, I forgot about the Con ;-) Have fun in California (and do
>> go shopping, it really pays right now *g*).
>>
>> Cheers,
>> Stefan
>>
>>
>>> /Eike
>>>
>>>
>>>
>>> Stefan Winkler schrieb:
>>>> Hi Eike,
>>>>
>>>> I'm running into the exception mentioned above. I'm not sure if
>>>> this is a bug or if I have to modify my generator model(s).
>>>> Here's the setting:
>>>>
>>>> I have two packages and a class in each one - I'll use a textual
>>>> notation to illustrate the EMF-Models:
>>>>
>>>> package base {
>>>> class BaseClass {
>>>> attribute counter : EInt;
>>>> operation increment() : void;
>>>> }
>>>> }
>>>>
>>>> package derived {
>>>> class DerivedClass extends base.BaseClass {
>>>> operation decrement() : void;
>>>> }
>>>> }
>>>>
>>>>
>>>> Package base is defined in base.ecore and base.genmodel. Package
>>>> derived is defined likewise in derived.ecore and derived.genmodel,
>>>> which refers to base.genmodel. Models validate correctly and model
>>>> code is generated as it should.
>>>>
>>>> (This is only an example which I extracted from my code, what I
>>>> really want is a package declaring a set of interfaces which
>>>> classes in other packages can implement, but the above is the code
>>>> I used to reproduce the problem, I can send you the test code if
>>>> you need it).
>>>>
>>>> Now, what I'm doing is simply creating a container, repository,
>>>> transaction, resource etc. and then:
>>>>
>>>> session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
>>>> session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);
>>>>
>>>>
>>>> The first call succeeds, the second one throws an exception:
>>>>
>>>> org.eclipse.net4j.util.io.IORuntimeException:
>>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>>> false)' is not contained in a resource.
>>>> at
>>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
>>>> at
>>>> org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
>>>>
>>>> at
>>>> org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
>>>>
>>>> at
>>>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
>>>>
>>>> at
>>>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
>>>>
>>>> at
>>>> test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
>>>> 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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
>>>>
>>>> at
>>>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
>>>>
>>>> at
>>>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>>>>
>>>> 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:460)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>>
>>>> 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:118)
>>>>
>>>> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
>>>> at
>>>> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
>>>>
>>>> at
>>>> org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
>>>> at
>>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
>>>> at
>>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
>>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
>>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
>>>> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
>>>> at
>>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
>>>>
>>>> at
>>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>>> at
>>>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>>>>
>>>> at
>>>> org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
>>>>
>>>> at
>>>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
>>>>
>>>> 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: 564)
>>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
>>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
>>>> Caused by:
>>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>>> false)' is not contained in a resource.
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
>>>>
>>>> at
>>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
>>>> ... 52 more
>>>> Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The
>>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>>> false)' is not contained in a resource.
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
>>>> ... 55 more
>>>>
>>>> So, is this a bug and CDO has Problems handling referenced
>>>> packages, or do I have to modify something in my models or code?
>>>>
>>>> (BTW, I updated to HEAD last Thrusday before testing this...)
>>>>
>>>> Cheers,
>>>> Stefan

--------------050407030807090701090105
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Eike,<br>
<br>
yesterday I updated to HEAD and tried my testcase and didn't catch an
exception. So I guess you fixed the bug?<br>
<br>
Next, I tried to run my project again with the fixed registry, but
again ran into trouble. <br>
<br>
What happens is this:<br>
<br>
So what I do is as follows:<br>
- I completely wipe the database (using the MySQL administrator, so it
is completely clean )<br>
- I start my application. As part of the initialization process, my
application registers a bunch of packages (say A, B, C and D in that
order) - all goes well.<br>
- I then create two objects - one of a class in package A and one of a
class in package C and commit my
model.<br>
- I exit the application.<br>
- I start the application again. As part of the initialization process,
for every package, I try to figure out, if the package is already
registered and if not I register it.<br>
<br>
I do this using the following code<br>
<br>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- ======================================================== --><!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = --><!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td align="left" nowrap="nowrap"
valign="top"> <code><font color="#7f0055"><b>private
Re: [CDO] DanglingHREFException after putEPackage() [message #116583 is a reply to message #116565] Thu, 03 April 2008 07:58 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Stefan,

Thanks for your detailed description. I won't have time before this
weekend to dig into this issue. In the meantime can you please file a
Bugzilla?

And, as you suspected, the previous issue should have been fixed already.
Due to the EclipseCon I only forgot to update the Bugzilla and tell on the
newsgroup.

Cheers
/Eike



Stefan Winkler wrote:

> Hi Eike,

> yesterday I updated to HEAD and tried my testcase and didn't catch an
> exception. So I guess you fixed the bug?

> Next, I tried to run my project again with the fixed registry, but again
> ran into trouble.

> What happens is this:

> So what I do is as follows:
> - I completely wipe the database (using the MySQL administrator, so it
> is completely clean )
> - I start my application. As part of the initialization process, my
> application registers a bunch of packages (say A, B, C and D in that
> order) - all goes well.
> - I then create two objects - one of a class in package A and one of a
> class in package C and commit my model.
> - I exit the application.
> - I start the application again. As part of the initialization process,
> for every package, I try to figure out, if the package is already
> registered and if not I register it.

> I do this using the following code

> |*private **void *registerPackage(EPackage pkg) {
> *if *(trace) {
> System.out.println("RequipseProjectPlugin.registerPackage("+
pkg.getNsURI() + ")");
> }

> CDOPackageRegistry packageRegistry = session.getPackageRegistry();
> CDOPackageManager packageManager = session.getPackageManager();

> CDOPackage existing = packageManager.lookupPackage(pkg.getNsURI());

> *if*(existing == *null*) {
> *try *{
> packageRegistry.putEPackage(pkg);
> *if *(trace) {
> System.out.println(" ... done.");
> }
> }
> *catch*(Exception e) {
> logException(e);
> }
> }
> *else if *(trace) {
> System.out.println(" ... already exists.");
> }
> }
> |


> The result of this is as follows:
> - The packages A and C (the ones I created the object with) are
> recognized as already registered in the code above.
> - The packages B and D are not recognized (|existing == null|).
> - Consequently they are tried to be registered, but this leads to a

> java.lang.ClassCastException:
> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl$CDOPacka geDescriptor
> cannot be cast to org.eclipse.emf.ecore.EPackage
> at org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:271)
> at
>
org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:163)
> at
> org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
> at
>
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
> at
>
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)

> The problem is this:
> - When the session is opened, the package registry seems to be populated
> with CDOPackageRegistryImpl$CDOPackageDescriptor instances in
> org.eclipse.emf.internal.cdo.CDOSessionPackageManagerImpl.
> addPackageProxies(...)

> - When I try to register an additional package,
> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString() iterates through the
> registry and casts all elements to EObject, which leads to the exception
> given above, because there still are
> CDOPackageRegistryImpl$CDOPackageDescriptor instances in the registry.


> Bug?

> Cheers,
> Stefan




> Eike Stepper schrieb:
>> Hi Stefan,
>>
>> I already worked a bit on a fix. But my time is a bit limited due to
>> all the interesting people and talks here at the EclipseCon ;-) I'l
>> keep you informed...
>>
>> Cheers
>> /Eike
>>
>>
>>
>> Stefan Winkler schrieb:
>>> Hi Eike,
>>>
>>> Comments below ...
>>>
>>> Eike Stepper schrieb:
>>>> Hi Stefan,
>>>>
>>>> This is clearly a bug in CDO. Fortunately it is really minor since
>>>> it occurs only when you add more than one package in one transaction
>>>> (commit). If you add them one by one everything should be fine.
>>> No, it doesn't :-( - maybe because the PackageManager is part of the
>>> session and not the transaction?
>>>
>>> I included my testcase as a Bug attachment.
>>>> Background: CDO converts the EPackages into CDOPackages and uses the
>>>> latter subsequently. In addition the EPackages are converted to XML
>>>> strings and stored in the backaend, just in case a client does not
>>>> have the generated Jva code at hand. Then the XML string would be
>>>> deserialized to the client so that it can use a dynamic model. Also
>>>> the new Hibernate integration will use this string on the server
>>>> side to get access to the mapping annotations.
>>>>
>>>> Can you please file a Bugzilla so that we can track the progress of
>>>> the fix?
>>> -> Bug 222974 <https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974>
>>>> Greeting from the EclipseCon ;-)
>>> Oh right, I forgot about the Con ;-) Have fun in California (and do
>>> go shopping, it really pays right now *g*).
>>>
>>> Cheers,
>>> Stefan
>>>
>>>
>>>> /Eike
>>>>
>>>>
>>>>
>>>> Stefan Winkler schrieb:
>>>>> Hi Eike,
>>>>>
>>>>> I'm running into the exception mentioned above. I'm not sure if
>>>>> this is a bug or if I have to modify my generator model(s).
>>>>> Here's the setting:
>>>>>
>>>>> I have two packages and a class in each one - I'll use a textual
>>>>> notation to illustrate the EMF-Models:
>>>>>
>>>>> package base {
>>>>> class BaseClass {
>>>>> attribute counter : EInt;
>>>>> operation increment() : void;
>>>>> }
>>>>> }
>>>>>
>>>>> package derived {
>>>>> class DerivedClass extends base.BaseClass {
>>>>> operation decrement() : void;
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>> Package base is defined in base.ecore and base.genmodel. Package
>>>>> derived is defined likewise in derived.ecore and derived.genmodel,
>>>>> which refers to base.genmodel. Models validate correctly and model
>>>>> code is generated as it should.
>>>>>
>>>>> (This is only an example which I extracted from my code, what I
>>>>> really want is a package declaring a set of interfaces which
>>>>> classes in other packages can implement, but the above is the code
>>>>> I used to reproduce the problem, I can send you the test code if
>>>>> you need it).
>>>>>
>>>>> Now, what I'm doing is simply creating a container, repository,
>>>>> transaction, resource etc. and then:
>>>>>
>>>>> session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
>>>>> session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);
>>>>>
>>>>>
>>>>> The first call succeeds, the second one throws an exception:
>>>>>
>>>>> org.eclipse.net4j.util.io.IORuntimeException:
>>>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>>>> false)' is not contained in a resource.
>>>>> at
>>>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
>>>>> at
>>>>>
org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
>>>>>
>>>>> at
>>>>> test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
>>>>> 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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>>>
>>>>> at
>>>>> org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
>>>>>
>>>>> at
>>>>>
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>>>>>
>>>>> 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:460)
>>>>>
>>>>> at
>>>>>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>>>
>>>>> at
>>>>>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>>>
>>>>> 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:118)
>>>>>
>>>>> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
>>>>> at
>>>>>
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
>>>>>
>>>>> at
>>>>> org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
>>>>> at
>>>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
>>>>> at
>>>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
>>>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
>>>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
>>>>> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
>>>>> at
>>>>>
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>>>
>>>>> at
>>>>>
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
>>>>>
>>>>> at
>>>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>>>> at
>>>>>
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>>>>>
>>>>> at
>>>>>
org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
>>>>>
>>>>> at
>>>>>
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>>>
>>>>> at
>>>>>
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>>>>>
>>>>> at
>>>>>
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>>>>>
>>>>> at
>>>>>
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
>>>>>
>>>>> at
>>>>>
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
>>>>>
>>>>> 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: 564)
>>>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
>>>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
>>>>> Caused by:
>>>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>>>> false)' is not contained in a resource.
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
>>>>> ... 52 more
>>>>> Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The
>>>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>>>> false)' is not contained in a resource.
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
>>>>> ... 55 more
>>>>>
>>>>> So, is this a bug and CDO has Problems handling referenced
>>>>> packages, or do I have to modify something in my models or code?
>>>>>
>>>>> (BTW, I updated to HEAD last Thrusday before testing this...)
>>>>>
>>>>> Cheers,
>>>>> Stefan


Re: [CDO] DanglingHREFException after putEPackage() [message #615902 is a reply to message #114899] Mon, 17 March 2008 12:38 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Stefan,

This is clearly a bug in CDO. Fortunately it is really minor since it occurs only when you add more than one package in one transaction (commit). If you add them one by one everything should be fine. Background: CDO converts the EPackages into CDOPackages and uses the latter subsequently. In addition the EPackages are converted to XML strings and stored in the backaend, just in case a client does not have the generated Jva code at hand. Then the XML string would be deserialized to the client so that it can use a dynamic model. Also the new Hibernate integration will use this string on the server side to get access to the mapping annotations.

Can you please file a Bugzilla so that we can track the progress of the fix?

Greeting from the EclipseCon ;-)
/Eike



Stefan Winkler schrieb:
> Hi Eike,
>
> I'm running into the exception mentioned above. I'm not sure if this is
> a bug or if I have to modify my generator model(s).
> Here's the setting:
>
> I have two packages and a class in each one - I'll use a textual
> notation to illustrate the EMF-Models:
>
> package base {
> class BaseClass {
> attribute counter : EInt;
> operation increment() : void;
> }
> }
>
> package derived {
> class DerivedClass extends base.BaseClass {
> operation decrement() : void;
> }
> }
>
>
> Package base is defined in base.ecore and base.genmodel. Package derived
> is defined likewise in derived.ecore and derived.genmodel, which refers
> to base.genmodel. Models validate correctly and model code is generated
> as it should.
>
> (This is only an example which I extracted from my code, what I really
> want is a package declaring a set of interfaces which classes in other
> packages can implement, but the above is the code I used to reproduce
> the problem, I can send you the test code if you need it).
>
> Now, what I'm doing is simply creating a container, repository,
> transaction, resource etc. and then:
>
> session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
> session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);
>
>
> The first call succeeds, the second one throws an exception:
>
> org.eclipse.net4j.util.io.IORuntimeException:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The object
> 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name: BaseClass)
> (instanceClassName: null) (abstract: false, interface: false)' is not
> contained in a resource.
> at org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
> at
> org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
>
> at
> org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
>
> at
> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
>
> at
> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
>
> at test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
> 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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
>
> at
> org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
>
> at
> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>
> at
> org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
>
> at
> org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
> at
> org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
>
> at
> org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
>
> at
> org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
>
> at
> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>
> at
> org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
> at
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>
> 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:460)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>
> at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>
> 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:118)
>
> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
> at
> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
>
> at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
> at
> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>
> at
> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
> at
> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>
> at
> org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
>
> at
> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>
> at
> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
>
> at
> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
>
> 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: 564)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
> Caused by: org.eclipse.emf.ecore.resource.Resource$IOWrappedException:
> The object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
> BaseClass) (instanceClassName: null) (abstract: false, interface:
> false)' is not contained in a resource.
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
>
> at org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
> ... 52 more
> Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The object
> 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name: BaseClass)
> (instanceClassName: null) (abstract: false, interface: false)' is not
> contained in a resource.
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
> ... 55 more
>
> So, is this a bug and CDO has Problems handling referenced packages, or
> do I have to modify something in my models or code?
>
> (BTW, I updated to HEAD last Thrusday before testing this...)
>
> Cheers,
> Stefan


Re: [CDO] DanglingHREFException after putEPackage() [message #615906 is a reply to message #114912] Mon, 17 March 2008 16:07 Go to previous message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 307
Registered: July 2009
Location: Germany
Senior Member
This is a multi-part message in MIME format.
--------------000309050507020903050007
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi Eike,

Comments below ...

Eike Stepper schrieb:
> Hi Stefan,
>
> This is clearly a bug in CDO. Fortunately it is really minor since it
> occurs only when you add more than one package in one transaction
> (commit). If you add them one by one everything should be fine.
No, it doesn't :-( - maybe because the PackageManager is part of the
session and not the transaction?

I included my testcase as a Bug attachment.
> Background: CDO converts the EPackages into CDOPackages and uses the
> latter subsequently. In addition the EPackages are converted to XML
> strings and stored in the backaend, just in case a client does not
> have the generated Jva code at hand. Then the XML string would be
> deserialized to the client so that it can use a dynamic model. Also
> the new Hibernate integration will use this string on the server side
> to get access to the mapping annotations.
>
> Can you please file a Bugzilla so that we can track the progress of
> the fix?
-> Bug 222974 <https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974>
> Greeting from the EclipseCon ;-)
Oh right, I forgot about the Con ;-) Have fun in California (and do go
shopping, it really pays right now *g*).

Cheers,
Stefan


> /Eike
>
>
>
> Stefan Winkler schrieb:
>> Hi Eike,
>>
>> I'm running into the exception mentioned above. I'm not sure if this
>> is a bug or if I have to modify my generator model(s).
>> Here's the setting:
>>
>> I have two packages and a class in each one - I'll use a textual
>> notation to illustrate the EMF-Models:
>>
>> package base {
>> class BaseClass {
>> attribute counter : EInt;
>> operation increment() : void;
>> }
>> }
>>
>> package derived {
>> class DerivedClass extends base.BaseClass {
>> operation decrement() : void;
>> }
>> }
>>
>>
>> Package base is defined in base.ecore and base.genmodel. Package
>> derived is defined likewise in derived.ecore and derived.genmodel,
>> which refers to base.genmodel. Models validate correctly and model
>> code is generated as it should.
>>
>> (This is only an example which I extracted from my code, what I
>> really want is a package declaring a set of interfaces which classes
>> in other packages can implement, but the above is the code I used to
>> reproduce the problem, I can send you the test code if you need it).
>>
>> Now, what I'm doing is simply creating a container, repository,
>> transaction, resource etc. and then:
>>
>> session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
>> session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);
>>
>>
>> The first call succeeds, the second one throws an exception:
>>
>> org.eclipse.net4j.util.io.IORuntimeException:
>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>> false)' is not contained in a resource.
>> at
>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
>> at
>> org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
>>
>> at
>> org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
>>
>> at
>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
>>
>> at
>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
>>
>> at
>> test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
>> 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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
>>
>> at
>> org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
>>
>> at
>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>
>> at
>> org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
>>
>> at
>> org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
>>
>> at
>> org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
>>
>> at
>> org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
>>
>> at
>> org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
>>
>> at
>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>
>> at
>> org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
>> at
>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>>
>> 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:460)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>
>> at
>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>
>> 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:118)
>>
>> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
>> at
>> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
>>
>> at
>> org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
>> at
>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
>> at
>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
>> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
>> at
>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>
>> at
>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
>>
>> at
>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>> at
>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>>
>> at
>> org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
>>
>> at
>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>
>> at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>>
>> at
>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
>>
>> at
>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
>>
>> 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: 564)
>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>> at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
>> at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
>> Caused by:
>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>> false)' is not contained in a resource.
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
>>
>> at
>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
>> ... 52 more
>> Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The
>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>> false)' is not contained in a resource.
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
>> ... 55 more
>>
>> So, is this a bug and CDO has Problems handling referenced packages,
>> or do I have to modify something in my models or code?
>>
>> (BTW, I updated to HEAD last Thrusday before testing this...)
>>
>> Cheers,
>> Stefan

--------------000309050507020903050007
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Eike,<br>
<br>
Comments below ...<br>
<br>
Eike Stepper schrieb:
<blockquote cite="mid:frlovc$fs3$1@build.eclipse.org" type="cite">Hi
Stefan,
<br>
<br>
This is clearly a bug in CDO. Fortunately it is really minor since it
occurs only when you add more than one package in one transaction
(commit). If you add them one by one everything should be fine. </blockquote>
No, it doesn't :-( - maybe because the PackageManager is part of the
session and not the transaction?<br>
<br>
I included my testcase as a Bug attachment.<br>
<blockquote cite="mid:frlovc$fs3$1@build.eclipse.org" type="cite">Background:
CDO converts the EPackages into CDOPackages and uses the latter
subsequently. In addition the EPackages are converted to XML strings
and stored in the backaend, just in case a client does not have the
generated Jva code at hand. Then the XML string would be deserialized
to the client so that it can use a dynamic model. Also the new
Hibernate integration will use this string on the server side to get
access to the mapping annotations.
<br>
<br>
Can you please file a Bugzilla so that we can track the progress of the
fix?
<br>
</blockquote>
-&gt; <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974"
title="NEW - [CDO] DanglingHREFException after putEPackage() when using referencing models">Bug
222974</a>
<blockquote cite="mid:frlovc$fs3$1@build.eclipse.org" type="cite">Greeting
from the EclipseCon ;-)
<br>
</blockquote>
Oh right, I forgot about the Con ;-) Have fun in California (and do go
shopping, it really pays right now *g*).<br>
<br>
Cheers,<br>
Stefan<br>
<br>
<br>
<blockquote cite="mid:frlovc$fs3$1@build.eclipse.org" type="cite">/Eike
<br>
<br>
<br>
<br>
Stefan Winkler schrieb:
<br>
<blockquote type="cite">Hi Eike,
<br>
<br>
I'm running into the exception mentioned above. I'm not sure if this is
a bug or if I have to modify my generator model(s).
<br>
Here's the setting:
<br>
<br>
I have two packages and a class in each one - I'll use a textual
notation to illustrate the EMF-Models:
<br>
<br>
package base {
<br>
Re: [CDO] DanglingHREFException after putEPackage() [message #615914 is a reply to message #114927] Mon, 17 March 2008 18:19 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Stefan,

I already worked a bit on a fix. But my time is a bit limited due to all the interesting people and talks here at the EclipseCon ;-) I'l keep you informed...

Cheers
/Eike



Stefan Winkler schrieb:
> Hi Eike,
>
> Comments below ...
>
> Eike Stepper schrieb:
>> Hi Stefan,
>>
>> This is clearly a bug in CDO. Fortunately it is really minor since it
>> occurs only when you add more than one package in one transaction
>> (commit). If you add them one by one everything should be fine.
> No, it doesn't :-( - maybe because the PackageManager is part of the
> session and not the transaction?
>
> I included my testcase as a Bug attachment.
>> Background: CDO converts the EPackages into CDOPackages and uses the
>> latter subsequently. In addition the EPackages are converted to XML
>> strings and stored in the backaend, just in case a client does not
>> have the generated Jva code at hand. Then the XML string would be
>> deserialized to the client so that it can use a dynamic model. Also
>> the new Hibernate integration will use this string on the server side
>> to get access to the mapping annotations.
>>
>> Can you please file a Bugzilla so that we can track the progress of
>> the fix?
> -> Bug 222974 <https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974>
>> Greeting from the EclipseCon ;-)
> Oh right, I forgot about the Con ;-) Have fun in California (and do go
> shopping, it really pays right now *g*).
>
> Cheers,
> Stefan
>
>
>> /Eike
>>
>>
>>
>> Stefan Winkler schrieb:
>>> Hi Eike,
>>>
>>> I'm running into the exception mentioned above. I'm not sure if this
>>> is a bug or if I have to modify my generator model(s).
>>> Here's the setting:
>>>
>>> I have two packages and a class in each one - I'll use a textual
>>> notation to illustrate the EMF-Models:
>>>
>>> package base {
>>> class BaseClass {
>>> attribute counter : EInt;
>>> operation increment() : void;
>>> }
>>> }
>>>
>>> package derived {
>>> class DerivedClass extends base.BaseClass {
>>> operation decrement() : void;
>>> }
>>> }
>>>
>>>
>>> Package base is defined in base.ecore and base.genmodel. Package
>>> derived is defined likewise in derived.ecore and derived.genmodel,
>>> which refers to base.genmodel. Models validate correctly and model
>>> code is generated as it should.
>>>
>>> (This is only an example which I extracted from my code, what I
>>> really want is a package declaring a set of interfaces which classes
>>> in other packages can implement, but the above is the code I used to
>>> reproduce the problem, I can send you the test code if you need it).
>>>
>>> Now, what I'm doing is simply creating a container, repository,
>>> transaction, resource etc. and then:
>>>
>>> session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
>>> session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);
>>>
>>>
>>> The first call succeeds, the second one throws an exception:
>>>
>>> org.eclipse.net4j.util.io.IORuntimeException:
>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>> false)' is not contained in a resource.
>>> at
>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
>>> at
>>> org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
>>>
>>> at
>>> org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
>>>
>>> at
>>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
>>>
>>> at
>>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
>>>
>>> at
>>> test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
>>> 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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
>>>
>>> at
>>> org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
>>>
>>> at
>>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>
>>> at
>>> org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
>>>
>>> at
>>> org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
>>>
>>> at
>>> org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
>>>
>>> at
>>> org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
>>>
>>> at
>>> org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
>>>
>>> at
>>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>
>>> at
>>> org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
>>> at
>>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>>>
>>> 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:460)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>
>>> 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:118)
>>>
>>> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
>>> at
>>> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
>>>
>>> at
>>> org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
>>> at
>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
>>> at
>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
>>> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
>>> at
>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>
>>> at
>>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
>>>
>>> at
>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>> at
>>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>>>
>>> at
>>> org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
>>>
>>> at
>>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>
>>> at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>>>
>>> at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>>>
>>> at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
>>>
>>> at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
>>>
>>> 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: 564)
>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
>>> Caused by:
>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>> false)' is not contained in a resource.
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
>>>
>>> at
>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
>>> ... 52 more
>>> Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The
>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>> false)' is not contained in a resource.
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
>>> ... 55 more
>>>
>>> So, is this a bug and CDO has Problems handling referenced packages,
>>> or do I have to modify something in my models or code?
>>>
>>> (BTW, I updated to HEAD last Thrusday before testing this...)
>>>
>>> Cheers,
>>> Stefan


Re: [CDO] DanglingHREFException after putEPackage() [message #615923 is a reply to message #114927] Mon, 17 March 2008 18:45 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Stefan Winkler schrieb:
> Hi Eike,
>
> Comments below ...
>
> Eike Stepper schrieb:
>> Hi Stefan,
>>
>> This is clearly a bug in CDO. Fortunately it is really minor since it
>> occurs only when you add more than one package in one transaction
>> (commit). If you add them one by one everything should be fine.
> No, it doesn't :-( - maybe because the PackageManager is part of the
> session and not the transaction?
>
> I included my testcase as a Bug attachment.

I'll work on it later on...

>> Background: CDO converts the EPackages into CDOPackages and uses the
>> latter subsequently. In addition the EPackages are converted to XML
>> strings and stored in the backaend, just in case a client does not
>> have the generated Jva code at hand. Then the XML string would be
>> deserialized to the client so that it can use a dynamic model. Also
>> the new Hibernate integration will use this string on the server side
>> to get access to the mapping annotations.
>>
>> Can you please file a Bugzilla so that we can track the progress of
>> the fix?
> -> Bug 222974 <https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974>
>> Greeting from the EclipseCon ;-)
> Oh right, I forgot about the Con ;-) Have fun in California (and do go
> shopping, it really pays right now *g*).

Oh, yeah! But I've been in New York in January and there's simply no more space available in our wardrobe ;-)

Cheers
/Eike


>
> Cheers,
> Stefan
>
>
>> /Eike
>>
>>
>>
>> Stefan Winkler schrieb:
>>> Hi Eike,
>>>
>>> I'm running into the exception mentioned above. I'm not sure if this
>>> is a bug or if I have to modify my generator model(s).
>>> Here's the setting:
>>>
>>> I have two packages and a class in each one - I'll use a textual
>>> notation to illustrate the EMF-Models:
>>>
>>> package base {
>>> class BaseClass {
>>> attribute counter : EInt;
>>> operation increment() : void;
>>> }
>>> }
>>>
>>> package derived {
>>> class DerivedClass extends base.BaseClass {
>>> operation decrement() : void;
>>> }
>>> }
>>>
>>>
>>> Package base is defined in base.ecore and base.genmodel. Package
>>> derived is defined likewise in derived.ecore and derived.genmodel,
>>> which refers to base.genmodel. Models validate correctly and model
>>> code is generated as it should.
>>>
>>> (This is only an example which I extracted from my code, what I
>>> really want is a package declaring a set of interfaces which classes
>>> in other packages can implement, but the above is the code I used to
>>> reproduce the problem, I can send you the test code if you need it).
>>>
>>> Now, what I'm doing is simply creating a container, repository,
>>> transaction, resource etc. and then:
>>>
>>> session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
>>> session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);
>>>
>>>
>>> The first call succeeds, the second one throws an exception:
>>>
>>> org.eclipse.net4j.util.io.IORuntimeException:
>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>> false)' is not contained in a resource.
>>> at
>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
>>> at
>>> org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
>>>
>>> at
>>> org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
>>>
>>> at
>>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
>>>
>>> at
>>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
>>>
>>> at
>>> test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
>>> 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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
>>>
>>> at
>>> org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
>>>
>>> at
>>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>
>>> at
>>> org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
>>>
>>> at
>>> org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
>>>
>>> at
>>> org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
>>>
>>> at
>>> org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
>>>
>>> at
>>> org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
>>>
>>> at
>>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>
>>> at
>>> org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
>>> at
>>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>>>
>>> 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:460)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>
>>> at
>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>
>>> 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:118)
>>>
>>> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
>>> at
>>> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
>>>
>>> at
>>> org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
>>> at
>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
>>> at
>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
>>> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
>>> at
>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>
>>> at
>>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
>>>
>>> at
>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>> at
>>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>>>
>>> at
>>> org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
>>>
>>> at
>>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>
>>> at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>>>
>>> at
>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>>>
>>> at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
>>>
>>> at
>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
>>>
>>> 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: 564)
>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
>>> Caused by:
>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>> false)' is not contained in a resource.
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
>>>
>>> at
>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
>>> ... 52 more
>>> Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The
>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>> false)' is not contained in a resource.
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
>>> ... 55 more
>>>
>>> So, is this a bug and CDO has Problems handling referenced packages,
>>> or do I have to modify something in my models or code?
>>>
>>> (BTW, I updated to HEAD last Thrusday before testing this...)
>>>
>>> Cheers,
>>> Stefan


Re: [CDO] DanglingHREFException after putEPackage() [message #616056 is a reply to message #114971] Wed, 02 April 2008 08:48 Go to previous message
Stefan Winkler is currently offline Stefan WinklerFriend
Messages: 307
Registered: July 2009
Location: Germany
Senior Member
This is a multi-part message in MIME format.
--------------050407030807090701090105
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi Eike,

yesterday I updated to HEAD and tried my testcase and didn't catch an
exception. So I guess you fixed the bug?

Next, I tried to run my project again with the fixed registry, but again
ran into trouble.

What happens is this:

So what I do is as follows:
- I completely wipe the database (using the MySQL administrator, so it
is completely clean )
- I start my application. As part of the initialization process, my
application registers a bunch of packages (say A, B, C and D in that
order) - all goes well.
- I then create two objects - one of a class in package A and one of a
class in package C and commit my model.
- I exit the application.
- I start the application again. As part of the initialization process,
for every package, I try to figure out, if the package is already
registered and if not I register it.

I do this using the following code

|*private **void *registerPackage(EPackage pkg) {
*if *(trace) {
System.out.println("RequipseProjectPlugin.registerPackage("+ pkg.getNsURI() + ")");
}

CDOPackageRegistry packageRegistry = session.getPackageRegistry();
CDOPackageManager packageManager = session.getPackageManager();

CDOPackage existing = packageManager.lookupPackage(pkg.getNsURI());

*if*(existing == *null*) {
*try *{
packageRegistry.putEPackage(pkg);
*if *(trace) {
System.out.println(" ... done.");
}
}
*catch*(Exception e) {
logException(e);
}
}
*else if *(trace) {
System.out.println(" ... already exists.");
}
}
|


The result of this is as follows:
- The packages A and C (the ones I created the object with) are
recognized as already registered in the code above.
- The packages B and D are not recognized (|existing == null|).
- Consequently they are tried to be registered, but this leads to a

java.lang.ClassCastException:
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl$CDOPacka geDescriptor
cannot be cast to org.eclipse.emf.ecore.EPackage
at org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:271)
at
org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:163)
at
org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
at
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
at
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)

The problem is this:
- When the session is opened, the package registry seems to be populated
with CDOPackageRegistryImpl$CDOPackageDescriptor instances in
org.eclipse.emf.internal.cdo.CDOSessionPackageManagerImpl.
addPackageProxies(...)

- When I try to register an additional package,
org.eclipse.emf.cdo.util.EMFUtil.ePackageToString() iterates through the
registry and casts all elements to EObject, which leads to the exception
given above, because there still are
CDOPackageRegistryImpl$CDOPackageDescriptor instances in the registry.


Bug?

Cheers,
Stefan




Eike Stepper schrieb:
> Hi Stefan,
>
> I already worked a bit on a fix. But my time is a bit limited due to
> all the interesting people and talks here at the EclipseCon ;-) I'l
> keep you informed...
>
> Cheers
> /Eike
>
>
>
> Stefan Winkler schrieb:
>> Hi Eike,
>>
>> Comments below ...
>>
>> Eike Stepper schrieb:
>>> Hi Stefan,
>>>
>>> This is clearly a bug in CDO. Fortunately it is really minor since
>>> it occurs only when you add more than one package in one transaction
>>> (commit). If you add them one by one everything should be fine.
>> No, it doesn't :-( - maybe because the PackageManager is part of the
>> session and not the transaction?
>>
>> I included my testcase as a Bug attachment.
>>> Background: CDO converts the EPackages into CDOPackages and uses the
>>> latter subsequently. In addition the EPackages are converted to XML
>>> strings and stored in the backaend, just in case a client does not
>>> have the generated Jva code at hand. Then the XML string would be
>>> deserialized to the client so that it can use a dynamic model. Also
>>> the new Hibernate integration will use this string on the server
>>> side to get access to the mapping annotations.
>>>
>>> Can you please file a Bugzilla so that we can track the progress of
>>> the fix?
>> -> Bug 222974 <https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974>
>>> Greeting from the EclipseCon ;-)
>> Oh right, I forgot about the Con ;-) Have fun in California (and do
>> go shopping, it really pays right now *g*).
>>
>> Cheers,
>> Stefan
>>
>>
>>> /Eike
>>>
>>>
>>>
>>> Stefan Winkler schrieb:
>>>> Hi Eike,
>>>>
>>>> I'm running into the exception mentioned above. I'm not sure if
>>>> this is a bug or if I have to modify my generator model(s).
>>>> Here's the setting:
>>>>
>>>> I have two packages and a class in each one - I'll use a textual
>>>> notation to illustrate the EMF-Models:
>>>>
>>>> package base {
>>>> class BaseClass {
>>>> attribute counter : EInt;
>>>> operation increment() : void;
>>>> }
>>>> }
>>>>
>>>> package derived {
>>>> class DerivedClass extends base.BaseClass {
>>>> operation decrement() : void;
>>>> }
>>>> }
>>>>
>>>>
>>>> Package base is defined in base.ecore and base.genmodel. Package
>>>> derived is defined likewise in derived.ecore and derived.genmodel,
>>>> which refers to base.genmodel. Models validate correctly and model
>>>> code is generated as it should.
>>>>
>>>> (This is only an example which I extracted from my code, what I
>>>> really want is a package declaring a set of interfaces which
>>>> classes in other packages can implement, but the above is the code
>>>> I used to reproduce the problem, I can send you the test code if
>>>> you need it).
>>>>
>>>> Now, what I'm doing is simply creating a container, repository,
>>>> transaction, resource etc. and then:
>>>>
>>>> session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
>>>> session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);
>>>>
>>>>
>>>> The first call succeeds, the second one throws an exception:
>>>>
>>>> org.eclipse.net4j.util.io.IORuntimeException:
>>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>>> false)' is not contained in a resource.
>>>> at
>>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
>>>> at
>>>> org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
>>>>
>>>> at
>>>> org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
>>>>
>>>> at
>>>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
>>>>
>>>> at
>>>> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
>>>>
>>>> at
>>>> test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
>>>> 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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
>>>>
>>>> at
>>>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
>>>>
>>>> at
>>>> org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>>
>>>> at
>>>> org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>>>>
>>>> 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:460)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>>
>>>> at
>>>> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>>
>>>> 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:118)
>>>>
>>>> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
>>>> at
>>>> org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
>>>>
>>>> at
>>>> org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
>>>> at
>>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
>>>> at
>>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
>>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
>>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
>>>> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
>>>> at
>>>> org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>>
>>>> at
>>>> org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
>>>>
>>>> at
>>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>>> at
>>>> org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>>>>
>>>> at
>>>> org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
>>>>
>>>> at
>>>> org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
>>>>
>>>> at
>>>> org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
>>>>
>>>> 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: 564)
>>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
>>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
>>>> Caused by:
>>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>>> false)' is not contained in a resource.
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
>>>>
>>>> at
>>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
>>>> ... 52 more
>>>> Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The
>>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>>> false)' is not contained in a resource.
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
>>>>
>>>> at
>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
>>>> ... 55 more
>>>>
>>>> So, is this a bug and CDO has Problems handling referenced
>>>> packages, or do I have to modify something in my models or code?
>>>>
>>>> (BTW, I updated to HEAD last Thrusday before testing this...)
>>>>
>>>> Cheers,
>>>> Stefan

--------------050407030807090701090105
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Eike,<br>
<br>
yesterday I updated to HEAD and tried my testcase and didn't catch an
exception. So I guess you fixed the bug?<br>
<br>
Next, I tried to run my project again with the fixed registry, but
again ran into trouble. <br>
<br>
What happens is this:<br>
<br>
So what I do is as follows:<br>
- I completely wipe the database (using the MySQL administrator, so it
is completely clean )<br>
- I start my application. As part of the initialization process, my
application registers a bunch of packages (say A, B, C and D in that
order) - all goes well.<br>
- I then create two objects - one of a class in package A and one of a
class in package C and commit my
model.<br>
- I exit the application.<br>
- I start the application again. As part of the initialization process,
for every package, I try to figure out, if the package is already
registered and if not I register it.<br>
<br>
I do this using the following code<br>
<br>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- ======================================================== --><!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = --><!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td align="left" nowrap="nowrap"
valign="top"> <code><font color="#7f0055"><b>private
Re: [CDO] DanglingHREFException after putEPackage() [message #616058 is a reply to message #116565] Thu, 03 April 2008 07:58 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Stefan,

Thanks for your detailed description. I won't have time before this
weekend to dig into this issue. In the meantime can you please file a
Bugzilla?

And, as you suspected, the previous issue should have been fixed already.
Due to the EclipseCon I only forgot to update the Bugzilla and tell on the
newsgroup.

Cheers
/Eike



Stefan Winkler wrote:

> Hi Eike,

> yesterday I updated to HEAD and tried my testcase and didn't catch an
> exception. So I guess you fixed the bug?

> Next, I tried to run my project again with the fixed registry, but again
> ran into trouble.

> What happens is this:

> So what I do is as follows:
> - I completely wipe the database (using the MySQL administrator, so it
> is completely clean )
> - I start my application. As part of the initialization process, my
> application registers a bunch of packages (say A, B, C and D in that
> order) - all goes well.
> - I then create two objects - one of a class in package A and one of a
> class in package C and commit my model.
> - I exit the application.
> - I start the application again. As part of the initialization process,
> for every package, I try to figure out, if the package is already
> registered and if not I register it.

> I do this using the following code

> |*private **void *registerPackage(EPackage pkg) {
> *if *(trace) {
> System.out.println("RequipseProjectPlugin.registerPackage("+
pkg.getNsURI() + ")");
> }

> CDOPackageRegistry packageRegistry = session.getPackageRegistry();
> CDOPackageManager packageManager = session.getPackageManager();

> CDOPackage existing = packageManager.lookupPackage(pkg.getNsURI());

> *if*(existing == *null*) {
> *try *{
> packageRegistry.putEPackage(pkg);
> *if *(trace) {
> System.out.println(" ... done.");
> }
> }
> *catch*(Exception e) {
> logException(e);
> }
> }
> *else if *(trace) {
> System.out.println(" ... already exists.");
> }
> }
> |


> The result of this is as follows:
> - The packages A and C (the ones I created the object with) are
> recognized as already registered in the code above.
> - The packages B and D are not recognized (|existing == null|).
> - Consequently they are tried to be registered, but this leads to a

> java.lang.ClassCastException:
> org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl$CDOPacka geDescriptor
> cannot be cast to org.eclipse.emf.ecore.EPackage
> at org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:271)
> at
>
org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:163)
> at
> org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
> at
>
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
> at
>
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)

> The problem is this:
> - When the session is opened, the package registry seems to be populated
> with CDOPackageRegistryImpl$CDOPackageDescriptor instances in
> org.eclipse.emf.internal.cdo.CDOSessionPackageManagerImpl.
> addPackageProxies(...)

> - When I try to register an additional package,
> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString() iterates through the
> registry and casts all elements to EObject, which leads to the exception
> given above, because there still are
> CDOPackageRegistryImpl$CDOPackageDescriptor instances in the registry.


> Bug?

> Cheers,
> Stefan




> Eike Stepper schrieb:
>> Hi Stefan,
>>
>> I already worked a bit on a fix. But my time is a bit limited due to
>> all the interesting people and talks here at the EclipseCon ;-) I'l
>> keep you informed...
>>
>> Cheers
>> /Eike
>>
>>
>>
>> Stefan Winkler schrieb:
>>> Hi Eike,
>>>
>>> Comments below ...
>>>
>>> Eike Stepper schrieb:
>>>> Hi Stefan,
>>>>
>>>> This is clearly a bug in CDO. Fortunately it is really minor since
>>>> it occurs only when you add more than one package in one transaction
>>>> (commit). If you add them one by one everything should be fine.
>>> No, it doesn't :-( - maybe because the PackageManager is part of the
>>> session and not the transaction?
>>>
>>> I included my testcase as a Bug attachment.
>>>> Background: CDO converts the EPackages into CDOPackages and uses the
>>>> latter subsequently. In addition the EPackages are converted to XML
>>>> strings and stored in the backaend, just in case a client does not
>>>> have the generated Jva code at hand. Then the XML string would be
>>>> deserialized to the client so that it can use a dynamic model. Also
>>>> the new Hibernate integration will use this string on the server
>>>> side to get access to the mapping annotations.
>>>>
>>>> Can you please file a Bugzilla so that we can track the progress of
>>>> the fix?
>>> -> Bug 222974 <https://bugs.eclipse.org/bugs/show_bug.cgi?id=222974>
>>>> Greeting from the EclipseCon ;-)
>>> Oh right, I forgot about the Con ;-) Have fun in California (and do
>>> go shopping, it really pays right now *g*).
>>>
>>> Cheers,
>>> Stefan
>>>
>>>
>>>> /Eike
>>>>
>>>>
>>>>
>>>> Stefan Winkler schrieb:
>>>>> Hi Eike,
>>>>>
>>>>> I'm running into the exception mentioned above. I'm not sure if
>>>>> this is a bug or if I have to modify my generator model(s).
>>>>> Here's the setting:
>>>>>
>>>>> I have two packages and a class in each one - I'll use a textual
>>>>> notation to illustrate the EMF-Models:
>>>>>
>>>>> package base {
>>>>> class BaseClass {
>>>>> attribute counter : EInt;
>>>>> operation increment() : void;
>>>>> }
>>>>> }
>>>>>
>>>>> package derived {
>>>>> class DerivedClass extends base.BaseClass {
>>>>> operation decrement() : void;
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>> Package base is defined in base.ecore and base.genmodel. Package
>>>>> derived is defined likewise in derived.ecore and derived.genmodel,
>>>>> which refers to base.genmodel. Models validate correctly and model
>>>>> code is generated as it should.
>>>>>
>>>>> (This is only an example which I extracted from my code, what I
>>>>> really want is a package declaring a set of interfaces which
>>>>> classes in other packages can implement, but the above is the code
>>>>> I used to reproduce the problem, I can send you the test code if
>>>>> you need it).
>>>>>
>>>>> Now, what I'm doing is simply creating a container, repository,
>>>>> transaction, resource etc. and then:
>>>>>
>>>>> session.getPackageRegistry().putEPackage(BasePackage.eINSTAN CE);
>>>>> session.getPackageRegistry().putEPackage(DerivedPackage.eINS TANCE);
>>>>>
>>>>>
>>>>> The first call succeeds, the second one throws an exception:
>>>>>
>>>>> org.eclipse.net4j.util.io.IORuntimeException:
>>>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>>>> false)' is not contained in a resource.
>>>>> at
>>>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:276)
>>>>> at
>>>>>
org.eclipse.emf.internal.cdo.util.ModelUtil.createCDOPackage (ModelUtil.java:162)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.internal.cdo.util.ModelUtil.getCDOPackage(Mo delUtil.java:128)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.put(CDOP ackageRegistryImpl.java:85)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.internal.cdo.CDOPackageRegistryImpl.putEPack age(CDOPackageRegistryImpl.java:64)
>>>>>
>>>>> at
>>>>> test.CDOPackageRefTests.testPutPackage(CDOPackageRefTests.ja va:97)
>>>>> 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.internal.runners.TestMethodRunner.executeMethodBod y(TestMethodRunner.java:99)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.TestMethodRunner.runUnprotected(T estMethodRunner.java:81)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.TestMethodRunner.runMethod(TestMe thodRunner.java:75)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.TestMethodRunner.run(TestMethodRu nner.java:45)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.TestClassMethodsRunner.invokeTest Method(TestClassMethodsRunner.java:66)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.TestClassMethodsRunner.run(TestCl assMethodsRunner.java:35)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.TestClassRunner$1.runUnprotected( TestClassRunner.java:42)
>>>>>
>>>>> at
>>>>>
org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAfterRunner.java:34)
>>>>>
>>>>> at
>>>>> org.junit.internal.runners.TestClassRunner.run(TestClassRunn er.java:52)
>>>>>
>>>>> at
>>>>>
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.r un(JUnit4TestReference.java:45)
>>>>>
>>>>> 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:460)
>>>>>
>>>>> at
>>>>>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTe sts(RemoteTestRunner.java:673)
>>>>>
>>>>> at
>>>>>
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(R emoteTestRunner.java:386)
>>>>>
>>>>> 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:118)
>>>>>
>>>>> at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:3 5)
>>>>> at
>>>>>
org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchr onizer.java:130)
>>>>>
>>>>> at
>>>>> org.eclipse.swt.widgets.Display.runAsyncMessages(Display.jav a:3737)
>>>>> at
>>>>> org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3374)
>>>>> at
>>>>> org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2392)
>>>>> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2356)
>>>>> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:22 22)
>>>>> at org.eclipse.ui.internal.Workbench$4.run(Workbench.java:474)
>>>>> at
>>>>>
org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:288)
>>>>>
>>>>> at
>>>>>
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:469)
>>>>>
>>>>> at
>>>>> org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
>>>>> at
>>>>>
org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:106)
>>>>>
>>>>> at
>>>>>
org.eclipse.pde.internal.junit.runtime.UITestApplication.sta rt(UITestApplication.java:52)
>>>>>
>>>>> at
>>>>>
org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:193)
>>>>>
>>>>> at
>>>>>
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:106)
>>>>>
>>>>> at
>>>>>
org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:76)
>>>>>
>>>>> at
>>>>>
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:362)
>>>>>
>>>>> at
>>>>>
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:175)
>>>>>
>>>>> 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: 564)
>>>>> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:504)
>>>>> at org.eclipse.equinox.launcher.Main.run(Main.java:1251)
>>>>> at org.eclipse.equinox.launcher.Main.main(Main.java:1227)
>>>>> Caused by:
>>>>> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: The
>>>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>>>> false)' is not contained in a resource.
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.endSave(XMLSaveIm pl.java:306)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:270)
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doSave(XMLRes ourceImpl.java:205)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:1313)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.cdo.util.EMFUtil.ePackageToString(EMFUtil.ja va:267)
>>>>> ... 52 more
>>>>> Caused by: org.eclipse.emf.ecore.xmi.DanglingHREFException: The
>>>>> object 'org.eclipse.emf.ecore.impl.EClassImpl@4f15c3 (name:
>>>>> BaseClass) (instanceClassName: null) (abstract: false, interface:
>>>>> false)' is not contained in a resource.
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:760)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:731)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:753)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefMany(XML SaveImpl.java:1983)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1335)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1154)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1015)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2366)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1513)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2665)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:669)
>>>>>
>>>>> at
>>>>>
org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:586)
>>>>>
>>>>> at
>>>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:256)
>>>>> ... 55 more
>>>>>
>>>>> So, is this a bug and CDO has Problems handling referenced
>>>>> packages, or do I have to modify something in my models or code?
>>>>>
>>>>> (BTW, I updated to HEAD last Thrusday before testing this...)
>>>>>
>>>>> Cheers,
>>>>> Stefan


Previous Topic:Workflow Engine ???
Next Topic:[Teneo] newbee question .. MappingException: Could not determine type for:
Goto Forum:
  


Current Time: Thu Apr 25 14:33:56 GMT 2024

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

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

Back to the top