Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » DanglingHREFException despite containment references
DanglingHREFException despite containment references [message #414714] Mon, 19 November 2007 22:22 Go to next message
Eclipse UserFriend
Originally posted by: matt.mcgill.gmail.com

Hey folks,

I'm using the Sample Reflective Ecore Model Editor to modify an
instance of an EMF metamodel. The metamodel defines three classes,
where once class has containment references to the other two, and
those two share a non-containment reference. Here's the elided metamodel:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
<ecore:EPackage name="Library" nsURI="http://www.cse.msu.edu/sens/Library" nsPrefix="lib">
<eClassifiers xsi:type="ecore:EClass" name="BookCopy">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="checkedIn" lowerBound="1" eType="/1/Boolean"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="info" lowerBound="1" eType="/0/BookInfo" eOpposite="/0/BookInfo/copy"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="library" lowerBound="1" eType="/0/Library" eOpposite="/0/Library/copy"/>
</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="BookInfo">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="title" lowerBound="1" eType="/1/String"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="isbn" lowerBound="1" eType="/1/Integer"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="copy" lowerBound="1" upperBound="-1" eType="/0/BookCopy" eOpposite="/0/BookCopy/info"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="librarys" lowerBound="1" upperBound="-1" eType="/0/Library" eOpposite="/0/Library/book"/>

</eClassifiers>
<eClassifiers xsi:type="ecore:EClass" name="Library">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="name" lowerBound="1" eType="/1/String"/>
<eStructuralFeatures xsi:type="ecore:EAttribute" name="location" lowerBound="1" eType="/1/String"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="book" upperBound="-1" eType="/0/BookInfo" containment="true" eOpposite="/0/BookInfo/librarys"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="copy" upperBound="-1" eType="/0/BookCopy" containment="true" eOpposite="/0/BookCopy/library"/>
</eClassifiers>
</ecore:EPackage>
<ecore:EPackage name="PrimitiveTypes" nsURI="urn:PrimitiveTypes.ecore" nsPrefix="PrimitiveTypes">
....snip...
</ecore:EPackage>
</xmi:XMI>

I created and saved the following instance of this metamodel:
<?xml version="1.0" encoding="ISO-8859-1"?>
<lib:Library xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:lib="http://www.cse.msu.edu/sens/Library" name="NY Public Library" location="New York">
<book title="Atlas Shrugged" isbn="12345"/>
<copy checkedIn="true"/>
</lib:Library>

However, when I attempt to relate the BookInfo and BookCopy instances via
the info/copy pair of EReferences, I get the following exception on save:
org.eclipse.emf.ecore.xmi.DanglingHREFException: The object 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@11a2dbe (eClass: org.eclipse.emf.ecore.impl.EClassImpl@1bb575a (name: BookInfo) (instanceClassName: null) (abstract: false, interface: false))' is
not contained in a resource.
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:759)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:730)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:752)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefSingle(X MLSaveImpl.java:1903)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1249)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2590)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1105)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:986)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2291)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1464)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2590)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:653)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:581)
at org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:253)
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:1253)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.saveOnlyIfC hangedWithMemoryBuffer(ResourceImpl.java:1083)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:956)
at org.eclipse.emf.ecore.presentation.EcoreEditor$11.execute(Ec oreEditor.java:1464)
at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(Worksp aceModifyOperation.java:101)
at org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1797)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(Workspac eModifyOperation.java:113)
at org.eclipse.jface.operation.ModalContext$ModalContextThread. run(ModalContext.java:113)

What's the deal? I'm certainly an EMF newcomer, so I expect I've something wrong.

Thanks,
-Matt McGill
Re: DanglingHREFException despite containment references [message #414716 is a reply to message #414714] Mon, 19 November 2007 22:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Matt,

If you validate this model (right click on the package and invoke
Validate...), does it producing errors about container references having
an upper bound of -1 being invalid? With EMF 2.3 it would, so "librarys"
upper bound needs to be set to 1. As long as the book info are both
contained by the library, relating those two things should not affect
their containment references with respect to the library but if you
model isn't well formed, all bets are off...


Matt McGill wrote:
> Hey folks,
>
> I'm using the Sample Reflective Ecore Model Editor to modify an
> instance of an EMF metamodel. The metamodel defines three classes,
> where once class has containment references to the other two, and
> those two share a non-containment reference. Here's the elided metamodel:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
> <ecore:EPackage name="Library"
> nsURI="http://www.cse.msu.edu/sens/Library" nsPrefix="lib">
> <eClassifiers xsi:type="ecore:EClass" name="BookCopy">
> <eStructuralFeatures xsi:type="ecore:EAttribute"
> name="checkedIn" lowerBound="1" eType="/1/Boolean"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="info"
> lowerBound="1" eType="/0/BookInfo" eOpposite="/0/BookInfo/copy"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="library"
> lowerBound="1" eType="/0/Library" eOpposite="/0/Library/copy"/>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="BookInfo">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="title"
> lowerBound="1" eType="/1/String"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="isbn"
> lowerBound="1" eType="/1/Integer"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="copy"
> lowerBound="1" upperBound="-1" eType="/0/BookCopy"
> eOpposite="/0/BookCopy/info"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="librarys"
> lowerBound="1" upperBound="-1" eType="/0/Library"
> eOpposite="/0/Library/book"/>
>
> </eClassifiers>
> <eClassifiers xsi:type="ecore:EClass" name="Library">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
> lowerBound="1" eType="/1/String"/>
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="location"
> lowerBound="1" eType="/1/String"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="book"
> upperBound="-1" eType="/0/BookInfo" containment="true"
> eOpposite="/0/BookInfo/librarys"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="copy"
> upperBound="-1" eType="/0/BookCopy" containment="true"
> eOpposite="/0/BookCopy/library"/>
> </eClassifiers>
> </ecore:EPackage>
> <ecore:EPackage name="PrimitiveTypes"
> nsURI="urn:PrimitiveTypes.ecore" nsPrefix="PrimitiveTypes">
> ....snip...
> </ecore:EPackage>
> </xmi:XMI>
>
> I created and saved the following instance of this metamodel:
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <lib:Library xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
> xmlns:lib="http://www.cse.msu.edu/sens/Library" name="NY Public
> Library" location="New York">
> <book title="Atlas Shrugged" isbn="12345"/>
> <copy checkedIn="true"/>
> </lib:Library>
>
> However, when I attempt to relate the BookInfo and BookCopy instances via
> the info/copy pair of EReferences, I get the following exception on save:
> org.eclipse.emf.ecore.xmi.DanglingHREFException: The object
> 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@11a2dbe (eClass:
> org.eclipse.emf.ecore.impl.EClassImpl@1bb575a (name: BookInfo)
> (instanceClassName: null) (abstract: false, interface: false))' is not
> contained in a resource.
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:759)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:730)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:752)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefSingle(X MLSaveImpl.java:1903)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1249)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2590)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1105)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:986)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2291)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1464)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2590)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:653)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:581)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:253)
> 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:1253)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.saveOnlyIfC hangedWithMemoryBuffer(ResourceImpl.java:1083)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:956)
>
> at
> org.eclipse.emf.ecore.presentation.EcoreEditor$11.execute(Ec oreEditor.java:1464)
>
> at
> org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(Worksp aceModifyOperation.java:101)
>
> at
> org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1797)
> at
> org.eclipse.ui.actions.WorkspaceModifyOperation.run(Workspac eModifyOperation.java:113)
>
> at
> org.eclipse.jface.operation.ModalContext$ModalContextThread. run(ModalContext.java:113)
>
>
> What's the deal? I'm certainly an EMF newcomer, so I expect I've
> something wrong.
>
> Thanks,
> -Matt McGill


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: DanglingHREFException despite containment references [message #414717 is a reply to message #414716] Mon, 19 November 2007 22:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: matt.mcgill.gmail.com

Ed Merks wrote:
Validation of the Library metamodel failed because of the upper bound,
as you anticipated. Unfortunately, fixing it does not solve the problem.

If it helps, when I validate the NY Public Library instance model, I
receive the following error:
The feature 'info' of 'Book Copy true' contains a dangling reference 'Book Info Atlas Shrugged'

-Matt McGill

> Matt,
>
> If you validate this model (right click on the package and invoke
> Validate...), does it producing errors about container references having
> an upper bound of -1 being invalid? With EMF 2.3 it would, so "librarys"
> upper bound needs to be set to 1. As long as the book info are both
> contained by the library, relating those two things should not affect
> their containment references with respect to the library but if you
> model isn't well formed, all bets are off...
>
>
> Matt McGill wrote:
>> Hey folks,
>>
>> I'm using the Sample Reflective Ecore Model Editor to modify an
>> instance of an EMF metamodel. The metamodel defines three classes,
>> where once class has containment references to the other two, and
>> those two share a non-containment reference. Here's the elided metamodel:
>>
>> <?xml version="1.0" encoding="ISO-8859-1"?>
>> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
>> <ecore:EPackage name="Library"
>> nsURI="http://www.cse.msu.edu/sens/Library" nsPrefix="lib">
>> <eClassifiers xsi:type="ecore:EClass" name="BookCopy">
>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>> name="checkedIn" lowerBound="1" eType="/1/Boolean"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="info"
>> lowerBound="1" eType="/0/BookInfo" eOpposite="/0/BookInfo/copy"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="library"
>> lowerBound="1" eType="/0/Library" eOpposite="/0/Library/copy"/>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="BookInfo">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="title"
>> lowerBound="1" eType="/1/String"/>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="isbn"
>> lowerBound="1" eType="/1/Integer"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="copy"
>> lowerBound="1" upperBound="-1" eType="/0/BookCopy"
>> eOpposite="/0/BookCopy/info"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="librarys"
>> lowerBound="1" upperBound="-1" eType="/0/Library"
>> eOpposite="/0/Library/book"/>
>>
>> </eClassifiers>
>> <eClassifiers xsi:type="ecore:EClass" name="Library">
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>> lowerBound="1" eType="/1/String"/>
>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="location"
>> lowerBound="1" eType="/1/String"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="book"
>> upperBound="-1" eType="/0/BookInfo" containment="true"
>> eOpposite="/0/BookInfo/librarys"/>
>> <eStructuralFeatures xsi:type="ecore:EReference" name="copy"
>> upperBound="-1" eType="/0/BookCopy" containment="true"
>> eOpposite="/0/BookCopy/library"/>
>> </eClassifiers>
>> </ecore:EPackage>
>> <ecore:EPackage name="PrimitiveTypes"
>> nsURI="urn:PrimitiveTypes.ecore" nsPrefix="PrimitiveTypes">
>> ....snip...
>> </ecore:EPackage>
>> </xmi:XMI>
>>
>> I created and saved the following instance of this metamodel:
>> <?xml version="1.0" encoding="ISO-8859-1"?>
>> <lib:Library xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>> xmlns:lib="http://www.cse.msu.edu/sens/Library" name="NY Public
>> Library" location="New York">
>> <book title="Atlas Shrugged" isbn="12345"/>
>> <copy checkedIn="true"/>
>> </lib:Library>
>>
>> However, when I attempt to relate the BookInfo and BookCopy instances via
>> the info/copy pair of EReferences, I get the following exception on save:
>> org.eclipse.emf.ecore.xmi.DanglingHREFException: The object
>> 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@11a2dbe (eClass:
>> org.eclipse.emf.ecore.impl.EClassImpl@1bb575a (name: BookInfo)
>> (instanceClassName: null) (abstract: false, interface: false))' is not
>> contained in a resource.
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:759)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:730)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:752)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefSingle(X MLSaveImpl.java:1903)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1249)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2590)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1105)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:986)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2291)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1464)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2590)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:653)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:581)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:253)
>> 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:1253)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.saveOnlyIfC hangedWithMemoryBuffer(ResourceImpl.java:1083)
>>
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:956)
>>
>> at
>> org.eclipse.emf.ecore.presentation.EcoreEditor$11.execute(Ec oreEditor.java:1464)
>>
>> at
>> org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(Worksp aceModifyOperation.java:101)
>>
>> at
>> org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1797)
>> at
>> org.eclipse.ui.actions.WorkspaceModifyOperation.run(Workspac eModifyOperation.java:113)
>>
>> at
>> org.eclipse.jface.operation.ModalContext$ModalContextThread. run(ModalContext.java:113)
>>
>>
>> What's the deal? I'm certainly an EMF newcomer, so I expect I've
>> something wrong.
>>
>> Thanks,
>> -Matt McGill
Re: DanglingHREFException despite containment references [message #414719 is a reply to message #414717] Tue, 20 November 2007 00:19 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Matt,

Probably you need to be more clear on exactly the steps needed to
reproduce this problem since on the surface this model sounds no
different than our standard example where the libary contains books and
writers and there is a bidirectional non-containment references between
books and writers. What do I need to do to reproduce your problem exactly?


Matt McGill wrote:
> Ed Merks wrote:
> Validation of the Library metamodel failed because of the upper bound,
> as you anticipated. Unfortunately, fixing it does not solve the problem.
>
> If it helps, when I validate the NY Public Library instance model, I
> receive the following error:
> The feature 'info' of 'Book Copy true' contains a dangling reference
> 'Book Info Atlas Shrugged'
>
> -Matt McGill
>
>> Matt,
>>
>> If you validate this model (right click on the package and invoke
>> Validate...), does it producing errors about container references
>> having an upper bound of -1 being invalid? With EMF 2.3 it would, so
>> "librarys" upper bound needs to be set to 1. As long as the book
>> info are both contained by the library, relating those two things
>> should not affect their containment references with respect to the
>> library but if you model isn't well formed, all bets are off...
>>
>>
>> Matt McGill wrote:
>>> Hey folks,
>>>
>>> I'm using the Sample Reflective Ecore Model Editor to modify an
>>> instance of an EMF metamodel. The metamodel defines three classes,
>>> where once class has containment references to the other two, and
>>> those two share a non-containment reference. Here's the elided
>>> metamodel:
>>>
>>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>> <xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>>> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore">
>>> <ecore:EPackage name="Library"
>>> nsURI="http://www.cse.msu.edu/sens/Library" nsPrefix="lib">
>>> <eClassifiers xsi:type="ecore:EClass" name="BookCopy">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>> name="checkedIn" lowerBound="1" eType="/1/Boolean"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="info"
>>> lowerBound="1" eType="/0/BookInfo" eOpposite="/0/BookInfo/copy"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>> name="library" lowerBound="1" eType="/0/Library"
>>> eOpposite="/0/Library/copy"/>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="BookInfo">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="title"
>>> lowerBound="1" eType="/1/String"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="isbn"
>>> lowerBound="1" eType="/1/Integer"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="copy"
>>> lowerBound="1" upperBound="-1" eType="/0/BookCopy"
>>> eOpposite="/0/BookCopy/info"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference"
>>> name="librarys" lowerBound="1" upperBound="-1" eType="/0/Library"
>>> eOpposite="/0/Library/book"/>
>>>
>>> </eClassifiers>
>>> <eClassifiers xsi:type="ecore:EClass" name="Library">
>>> <eStructuralFeatures xsi:type="ecore:EAttribute" name="name"
>>> lowerBound="1" eType="/1/String"/>
>>> <eStructuralFeatures xsi:type="ecore:EAttribute"
>>> name="location" lowerBound="1" eType="/1/String"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="book"
>>> upperBound="-1" eType="/0/BookInfo" containment="true"
>>> eOpposite="/0/BookInfo/librarys"/>
>>> <eStructuralFeatures xsi:type="ecore:EReference" name="copy"
>>> upperBound="-1" eType="/0/BookCopy" containment="true"
>>> eOpposite="/0/BookCopy/library"/>
>>> </eClassifiers>
>>> </ecore:EPackage>
>>> <ecore:EPackage name="PrimitiveTypes"
>>> nsURI="urn:PrimitiveTypes.ecore" nsPrefix="PrimitiveTypes">
>>> ....snip...
>>> </ecore:EPackage>
>>> </xmi:XMI>
>>>
>>> I created and saved the following instance of this metamodel:
>>> <?xml version="1.0" encoding="ISO-8859-1"?>
>>> <lib:Library xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"
>>> xmlns:lib="http://www.cse.msu.edu/sens/Library" name="NY Public
>>> Library" location="New York">
>>> <book title="Atlas Shrugged" isbn="12345"/>
>>> <copy checkedIn="true"/>
>>> </lib:Library>
>>>
>>> However, when I attempt to relate the BookInfo and BookCopy
>>> instances via
>>> the info/copy pair of EReferences, I get the following exception on
>>> save:
>>> org.eclipse.emf.ecore.xmi.DanglingHREFException: The object
>>> 'org.eclipse.emf.ecore.impl.DynamicEObjectImpl@11a2dbe (eClass:
>>> org.eclipse.emf.ecore.impl.EClassImpl@1bb575a (name: BookInfo)
>>> (instanceClassName: null) (abstract: false, interface: false))' is
>>> not contained in a resource.
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.handleDanglingH REF(XMLHelperImpl.java:759)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getURIFragment( XMLHelperImpl.java:730)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.getIDREF(XMLHel perImpl.java:752)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveIDRefSingle(X MLSaveImpl.java:1903)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1249)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2590)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:1105)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElement(XMLSa veImpl.java:986)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveContainedMany (XMLSaveImpl.java:2291)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveFeatures(XMLS aveImpl.java:1464)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.saveElementID(XML SaveImpl.java:2590)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.writeTopObject(XM LSaveImpl.java:653)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.traverse(XMLSaveI mpl.java:581)
>>>
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLSaveImpl.save(XMLSaveImpl. java:253)
>>> 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:1253)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.saveOnlyIfC hangedWithMemoryBuffer(ResourceImpl.java:1083)
>>>
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.save(Resour ceImpl.java:956)
>>>
>>> at
>>> org.eclipse.emf.ecore.presentation.EcoreEditor$11.execute(Ec oreEditor.java:1464)
>>>
>>> at
>>> org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(Worksp aceModifyOperation.java:101)
>>>
>>> at
>>> org.eclipse.core.internal.resources.Workspace.run(Workspace. java:1797)
>>> at
>>> org.eclipse.ui.actions.WorkspaceModifyOperation.run(Workspac eModifyOperation.java:113)
>>>
>>> at
>>> org.eclipse.jface.operation.ModalContext$ModalContextThread. run(ModalContext.java:113)
>>>
>>>
>>> What's the deal? I'm certainly an EMF newcomer, so I expect I've
>>> something wrong.
>>>
>>> Thanks,
>>> -Matt McGill


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Is it possible to specify generated model code prefix and suffix?
Next Topic:EMF load resource behavior when the resource is a Database via Teneo
Goto Forum:
  


Current Time: Fri Apr 26 19:08:51 GMT 2024

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

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

Back to the top