Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » XMI Deserialization problem
XMI Deserialization problem [message #526799] Tue, 13 April 2010 00:32 Go to next message
Stephen McCants is currently offline Stephen McCantsFriend
Messages: 92
Registered: July 2009
Member
Hello,
I have a problem with XMI deserialization. I have two programs and they are passing EMF objects
back and forth using XMI. First, the sending application (1) creates an XMIResource in Resource Set
1 and adds Object A to it and send it to the receiving application (2). The receiving application
(2) recreates Object A in a Resource in Resource Set 2. Now the sending application(1) creates a
new XMIResource in ResourceSet1 and creates Object B which has a non-containment reference to Object
A. It then sends Object B (using its Resource) to the receiving application(2). The receiving
application(2) creates a new Resource in ResourceSet2 and has that resource read the XMI in to
create Object B. However it fails with this:

org.eclipse.emf.ecore.xmi.UnresolvedReferenceException: Unresolved reference '1'.
( dbo://localhost/junit/storage/JUNIT/MODEL/4d90ff32-a700-47bb -a1d7-5f371bf86536, 2, 398)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1154)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1228)
at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unkn own Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unkn own Source)
at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDi spatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unk nown Source)
at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
... 71 more

The reference is correct (I believe) as the Object A is at URI/1 and Object B is at
URI/4d90ff32-a700-47bb-a1d7-5f371bf86536 in both resource sets. It looks like the XMLHandler is
only looking in Object B's resource for Object A, when it should either create a proxy or look in
Object B's resource set.
The URIs for the mirroring resources end the same way on both sides, but start very differently
(different schemes and different paths up until the last 2-3 segments).
Am I missing something here? I've been able to pass cross-document proxies in the past.
Thanks in advance!

Sincerely,
Stephen McCants
Re: XMI Deserialization problem [message #526951 is a reply to message #526799] Tue, 13 April 2010 14:50 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Stephen,

Comments below.

Stephen McCants wrote:
> Hello,
> I have a problem with XMI deserialization. I have two programs
> and they are passing EMF objects back and forth using XMI. First, the
> sending application (1) creates an XMIResource in Resource Set 1 and
> adds Object A to it and send it to the receiving application (2). The
> receiving application (2) recreates Object A in a Resource in Resource
> Set 2. Now the sending application(1) creates a new XMIResource in
> ResourceSet1 and creates Object B which has a non-containment
> reference to Object A. It then sends Object B (using its Resource) to
> the receiving application(2). The receiving application(2) creates a
> new Resource in ResourceSet2 and has that resource read the XMI in to
> create Object B. However it fails with this:
>
> org.eclipse.emf.ecore.xmi.UnresolvedReferenceException: Unresolved
> reference '1'.
> ( dbo://localhost/junit/storage/JUNIT/MODEL/4d90ff32-a700-47bb -a1d7-5f371bf86536,
> 2, 398)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1154)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1228)
>
> at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unkn own
> Source)
> at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unkn own
> Source)
> at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
> at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
> at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
> at
> org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDi spatcher.dispatch(Unknown
> Source)
> at
> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown
> Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
> at
> org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unk nown Source)
> at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
> ... 71 more
This looks like the handling of a same document reference, not a cross
resource reference.
>
> The reference is correct (I believe) as the Object A is at URI/1 and
> Object B is at URI/4d90ff32-a700-47bb-a1d7-5f371bf86536 in both
> resource sets. It looks like the XMLHandler is only looking in Object
> B's resource for Object A,
Indeed.
> when it should either create a proxy or look in Object B's resource set.
That depends on the form of the URI. What does it actually look like?
> The URIs for the mirroring resources end the same way on both
> sides, but start very differently (different schemes and different
> paths up until the last 2-3 segments).
So as long as the paths are relatively correct it should be fine, but it
really looks like a same document reference and that really is only
produced if the objects are in the same resource when they're serialized.
> Am I missing something here? I've been able to pass
> cross-document proxies in the past.
Check carefully before you serialize B what A's eResource() method
returns...
> Thanks in advance!
>
> Sincerely,
> Stephen McCants


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: XMI Deserialization problem [message #526985 is a reply to message #526951] Tue, 13 April 2010 15:49 Go to previous message
Stephen McCants is currently offline Stephen McCantsFriend
Messages: 92
Registered: July 2009
Member
Hi Ed,
Thanks for your help. You put me on the right track and I found and solved the problem in my code.
Thanks!

--Stephen

Ed Merks wrote:
> Stephen,
>
> Comments below.
>
> Stephen McCants wrote:
>> Hello,
>> I have a problem with XMI deserialization. I have two programs
>> and they are passing EMF objects back and forth using XMI. First, the
>> sending application (1) creates an XMIResource in Resource Set 1 and
>> adds Object A to it and send it to the receiving application (2). The
>> receiving application (2) recreates Object A in a Resource in Resource
>> Set 2. Now the sending application(1) creates a new XMIResource in
>> ResourceSet1 and creates Object B which has a non-containment
>> reference to Object A. It then sends Object B (using its Resource) to
>> the receiving application(2). The receiving application(2) creates a
>> new Resource in ResourceSet2 and has that resource read the XMI in to
>> create Object B. However it fails with this:
>>
>> org.eclipse.emf.ecore.xmi.UnresolvedReferenceException: Unresolved
>> reference '1'.
>> ( dbo://localhost/junit/storage/JUNIT/MODEL/4d90ff32-a700-47bb -a1d7-5f371bf86536,
>> 2, 398)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleForwardRefer ences(XMLHandler.java:1154)
>>
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.endDocument(XMLHan dler.java:1228)
>>
>> at org.apache.xerces.parsers.AbstractSAXParser.endDocument(Unkn own
>> Source)
>> at org.apache.xerces.impl.XMLDocumentScannerImpl.endEntity(Unkn own
>> Source)
>> at org.apache.xerces.impl.XMLEntityManager.endEntity(Unknown Source)
>> at org.apache.xerces.impl.XMLEntityScanner.load(Unknown Source)
>> at org.apache.xerces.impl.XMLEntityScanner.skipSpaces(Unknown Source)
>> at
>> org.apache.xerces.impl.XMLDocumentScannerImpl$TrailingMiscDi spatcher.dispatch(Unknown
>> Source)
>> at
>> org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDo cument(Unknown
>> Source)
>> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>> at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
>> at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
>> at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
>> at
>> org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unk nown Source)
>> at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
>> ... 71 more
> This looks like the handling of a same document reference, not a cross
> resource reference.
>>
>> The reference is correct (I believe) as the Object A is at URI/1 and
>> Object B is at URI/4d90ff32-a700-47bb-a1d7-5f371bf86536 in both
>> resource sets. It looks like the XMLHandler is only looking in Object
>> B's resource for Object A,
> Indeed.
>> when it should either create a proxy or look in Object B's resource set.
> That depends on the form of the URI. What does it actually look like?
>> The URIs for the mirroring resources end the same way on both
>> sides, but start very differently (different schemes and different
>> paths up until the last 2-3 segments).
> So as long as the paths are relatively correct it should be fine, but it
> really looks like a same document reference and that really is only
> produced if the objects are in the same resource when they're serialized.
>> Am I missing something here? I've been able to pass
>> cross-document proxies in the past.
> Check carefully before you serialize B what A's eResource() method
> returns...
>> Thanks in advance!
>>
>> Sincerely,
>> Stephen McCants
Previous Topic:ECoreUtil.copy() not copying a proxy object
Next Topic:How to get ItemProviderAdapter for EStructuralFeature
Goto Forum:
  


Current Time: Wed Apr 24 15:42:42 GMT 2024

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

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

Back to the top