Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Re: metamodel conflict while reading xmi file
Re: metamodel conflict while reading xmi file [message #476393] Wed, 17 October 2007 11:21 Go to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33136
Registered: July 2009
Senior Member
Daniel,

It seems to me that the UML2 project provides a specialized resource
factory that you should be using instead. So it's best to read the UML
documentation and ask questions about problems on the UML2 newsgroup,
which I've added to the "to" list of the reply.

In general accessing XyzPackage.eINSTANCE.eClass() will register that
package in the EPackage.Registry.INSTANCE, but a resource set has a
local getPackageRegistry() and you can register things locally to hide
or augment the global registrations...


Daniel Lucredio wrote:
> Hi everybody, I've been looking for a solution for this, and I still
> found no answers, maybe you guys can help.
>
> I am developing a stand-alone application for dynamically loading
> several XMI files using EMF. Each file can refer to a different
> package - or metamodel - (ex: uml2, gmf, or my own ecore metamodel),
> through a different namespace in the xmi file. I've followed the EMF
> tutorial for doing this, and it works fine:
>
> // Initialize the resource set.
> ResourceSet resourceSet = new ResourceSetImpl();
> // Register the default resource factory -- only needed for
> stand-alone!
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(
> Resource.Factory.Registry.DEFAULT_EXTENSION, new
> XMIResourceFactoryImpl());
>
> // Register the package
> UMLPackage.eINSTANCE.eClass();
>
> URI fileURI = URI.createFileURI(file.getAbsolutePath());
>
> // Demand load the resource for this file.
> Resource resource = resourceSet.getResource(fileURI, true);
>
> However, some of my files are use two different versions of the UML
> metamodel (1.0.0 and 2.2.0). If I read them separately (two executions
> of the main method), it works. However, if I try to load them in the
> same execution (meaning that both metamodels - jar files - are loaded
> into the JVM at the same time), there seems to be some conflict, and
> an exception is thrown:
>
> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
> 'base_Activity' not found.
> (file:/C:/eclipseWorkspace/StandaloneEMFTest/models/Sample1. uml, 667,
> 103)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeatu re(XMLHandler.java:1856)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeatu re(XMLHandler.java:1820)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.handleUnknownFeatu re(XMIHandler.java:149)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XML Handler.java:2570)
>
> at
> org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAtt ribs(SAXXMIHandler.java:76)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2058)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1270)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1336)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:970)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:953)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:684)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
>
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocume ntParser.emptyElement(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
> Source)
> at javax.xml.parsers.SAXParser.parse(Unknown Source)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:179)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1354)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1155)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:256)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:271)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:398)
>
>
> Maybe it's because some elements have the same name in the different
> versions of UML, and EMF is getting lost. I am not sure about this.
> Also, depending on the order I load the files, it works: If I load a
> UML 1.0.0 file first, it works, but if I load the UML 2.2.0 first, the
> error occurs.
>
> What I want to do is to consider one metamodel at a time. For example:
> while reading a file for UML 2.2.0, only the UML 2.2.0 package is
> loaded. Then, I want to unload it, load another version of UML, and
> then read the file, so that there won't be any conflicts.
>
> However, the only way of registering these packages is by accessing
> the eINSTANCE field, which triggers some init() method that already
> loads the classes into some kind of global registry, and I am unable
> to unload them after that. Is there another way of registering the
> metamodel packages other than by using the eINSTANCE field(), so that
> I can try to use some custom class loader, for example, and have more
> control over which classes are loaded?
>
> Thanks
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: metamodel conflict while reading xmi file [message #476394 is a reply to message #476393] Wed, 17 October 2007 13:24 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
This appears to be a problem with profiles - the 'base_Activity' feature is
most likely a reference from the Ecore representation of a stereotype to its
metaclass.

Note that specific options are required in order to successfully load a UML
resource; these are turned on by default in the UML resource implementation,
and I suspect the situtation is similar for other resource types... so I
wouldn't recommend trying to load different resource types using the same
resource implementation (i.e. the default XMI one).

Kenn

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:ff4r8i$aqi$1@build.eclipse.org...
> Daniel,
>
> It seems to me that the UML2 project provides a specialized resource
> factory that you should be using instead. So it's best to read the UML
> documentation and ask questions about problems on the UML2 newsgroup,
> which I've added to the "to" list of the reply.
>
> In general accessing XyzPackage.eINSTANCE.eClass() will register that
> package in the EPackage.Registry.INSTANCE, but a resource set has a local
> getPackageRegistry() and you can register things locally to hide or
> augment the global registrations...
>
>
> Daniel Lucredio wrote:
>> Hi everybody, I've been looking for a solution for this, and I still
>> found no answers, maybe you guys can help.
>>
>> I am developing a stand-alone application for dynamically loading several
>> XMI files using EMF. Each file can refer to a different package - or
>> metamodel - (ex: uml2, gmf, or my own ecore metamodel), through a
>> different namespace in the xmi file. I've followed the EMF tutorial for
>> doing this, and it works fine:
>>
>> // Initialize the resource set.
>> ResourceSet resourceSet = new ResourceSetImpl();
>> // Register the default resource factory -- only needed for
>> stand-alone!
>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(
>> Resource.Factory.Registry.DEFAULT_EXTENSION, new
>> XMIResourceFactoryImpl());
>>
>> // Register the package
>> UMLPackage.eINSTANCE.eClass();
>>
>> URI fileURI = URI.createFileURI(file.getAbsolutePath());
>>
>> // Demand load the resource for this file.
>> Resource resource = resourceSet.getResource(fileURI, true);
>>
>> However, some of my files are use two different versions of the UML
>> metamodel (1.0.0 and 2.2.0). If I read them separately (two executions of
>> the main method), it works. However, if I try to load them in the same
>> execution (meaning that both metamodels - jar files - are loaded into the
>> JVM at the same time), there seems to be some conflict, and an exception
>> is thrown:
>>
>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
>> 'base_Activity' not found.
>> (file:/C:/eclipseWorkspace/StandaloneEMFTest/models/Sample1. uml, 667,
>> 103)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeatu re(XMLHandler.java:1856)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeatu re(XMLHandler.java:1820)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.handleUnknownFeatu re(XMIHandler.java:149)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XML Handler.java:2570)
>> at
>> org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAtt ribs(SAXXMIHandler.java:76)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2058)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1270)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1336)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:970)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:953)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:684)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
>> at
>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocume ntParser.emptyElement(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>> Source)
>> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>> Source)
>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:179)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1354)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1155)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:256)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:271)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:398)
>>
>> Maybe it's because some elements have the same name in the different
>> versions of UML, and EMF is getting lost. I am not sure about this. Also,
>> depending on the order I load the files, it works: If I load a UML 1.0.0
>> file first, it works, but if I load the UML 2.2.0 first, the error
>> occurs.
>>
>> What I want to do is to consider one metamodel at a time. For example:
>> while reading a file for UML 2.2.0, only the UML 2.2.0 package is loaded.
>> Then, I want to unload it, load another version of UML, and then read the
>> file, so that there won't be any conflicts.
>>
>> However, the only way of registering these packages is by accessing the
>> eINSTANCE field, which triggers some init() method that already loads the
>> classes into some kind of global registry, and I am unable to unload them
>> after that. Is there another way of registering the metamodel packages
>> other than by using the eINSTANCE field(), so that I can try to use some
>> custom class loader, for example, and have more control over which
>> classes are loaded?
>>
>> Thanks
>>
Re: metamodel conflict while reading xmi file [message #476397 is a reply to message #476394] Wed, 17 October 2007 16:36 Go to previous message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Just a suggestion Daniel, but my thought is that you should first
convert to common representation, e.g. 1.0.0 to 2.2.0, before actually
loading them..

On 2007-10-17 06:24:08 -0700, "Kenn Hussey" <Kenn.Hussey@embarcadero.com> said:

> This appears to be a problem with profiles - the 'base_Activity'
> feature is most likely a reference from the Ecore representation of a
> stereotype to its metaclass.
>
> Note that specific options are required in order to successfully load a
> UML resource; these are turned on by default in the UML resource
> implementation, and I suspect the situtation is similar for other
> resource types... so I wouldn't recommend trying to load different
> resource types using the same resource implementation (i.e. the default
> XMI one).
>
> Kenn
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:ff4r8i$aqi$1@build.eclipse.org...
>> Daniel,
>>
>> It seems to me that the UML2 project provides a specialized resource
>> factory that you should be using instead. So it's best to read the UML
>> documentation and ask questions about problems on the UML2 newsgroup,
>> which I've added to the "to" list of the reply.
>>
>> In general accessing XyzPackage.eINSTANCE.eClass() will register that
>> package in the EPackage.Registry.INSTANCE, but a resource set has a
>> local getPackageRegistry() and you can register things locally to hide
>> or augment the global registrations...
>>
>>
>> Daniel Lucredio wrote:
>>> Hi everybody, I've been looking for a solution for this, and I still
>>> found no answers, maybe you guys can help.
>>>
>>> I am developing a stand-alone application for dynamically loading
>>> several XMI files using EMF. Each file can refer to a different package
>>> - or metamodel - (ex: uml2, gmf, or my own ecore metamodel), through a
>>> different namespace in the xmi file. I've followed the EMF tutorial for
>>> doing this, and it works fine:
>>>
>>> // Initialize the resource set.
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>> // Register the default resource factory -- only needed for stand-alone!
>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(
>>> Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
>>>
>>> // Register the package
>>> UMLPackage.eINSTANCE.eClass();
>>>
>>> URI fileURI = URI.createFileURI(file.getAbsolutePath());
>>>
>>> // Demand load the resource for this file.
>>> Resource resource = resourceSet.getResource(fileURI, true);
>>>
>>> However, some of my files are use two different versions of the UML
>>> metamodel (1.0.0 and 2.2.0). If I read them separately (two executions
>>> of the main method), it works. However, if I try to load them in the
>>> same execution (meaning that both metamodels - jar files - are loaded
>>> into the JVM at the same time), there seems to be some conflict, and an
>>> exception is thrown:
>>>
>>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
>>> 'base_Activity' not found.
>>> (file:/C:/eclipseWorkspace/StandaloneEMFTest/models/Sample1. uml, 667,
>>> 103)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeatu re(XMLHandler.java:1856)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeatu re(XMLHandler.java:1820)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.handleUnknownFeatu re(XMIHandler.java:149)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XML Handler.java:2570)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAtt ribs(SAXXMIHandler.java:76)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2058)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1270)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1336)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:970)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
>>> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:953)
>>> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:684)
>>> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocume ntParser.emptyElement(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>> Source)
>>> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>>> Source)
>>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:179)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at
>>>
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1354)
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1155)
at
>>>
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:256)
at
>>>
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:271)
at
>>>
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:398)

Maybe
>>>
>>> it's because some elements have the same name in the different versions
>>> of UML, and EMF is getting lost. I am not sure about this. Also,
>>> depending on the order I load the files, it works: If I load a UML
>>> 1.0.0 file first, it works, but if I load the UML 2.2.0 first, the
>>> error occurs.
>>>
>>> What I want to do is to consider one metamodel at a time. For example:
>>> while reading a file for UML 2.2.0, only the UML 2.2.0 package is
>>> loaded. Then, I want to unload it, load another version of UML, and
>>> then read the file, so that there won't be any conflicts.
>>>
>>> However, the only way of registering these packages is by accessing the
>>> eINSTANCE field, which triggers some init() method that already loads
>>> the classes into some kind of global registry, and I am unable to
>>> unload them after that. Is there another way of registering the
>>> metamodel packages other than by using the eINSTANCE field(), so that I
>>> can try to use some custom class loader, for example, and have more
>>> control over which classes are loaded?
>>>
>>> Thanks
Re: metamodel conflict while reading xmi file [message #625227 is a reply to message #476393] Wed, 17 October 2007 13:24 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
This appears to be a problem with profiles - the 'base_Activity' feature is
most likely a reference from the Ecore representation of a stereotype to its
metaclass.

Note that specific options are required in order to successfully load a UML
resource; these are turned on by default in the UML resource implementation,
and I suspect the situtation is similar for other resource types... so I
wouldn't recommend trying to load different resource types using the same
resource implementation (i.e. the default XMI one).

Kenn

"Ed Merks" <merks@ca.ibm.com> wrote in message
news:ff4r8i$aqi$1@build.eclipse.org...
> Daniel,
>
> It seems to me that the UML2 project provides a specialized resource
> factory that you should be using instead. So it's best to read the UML
> documentation and ask questions about problems on the UML2 newsgroup,
> which I've added to the "to" list of the reply.
>
> In general accessing XyzPackage.eINSTANCE.eClass() will register that
> package in the EPackage.Registry.INSTANCE, but a resource set has a local
> getPackageRegistry() and you can register things locally to hide or
> augment the global registrations...
>
>
> Daniel Lucredio wrote:
>> Hi everybody, I've been looking for a solution for this, and I still
>> found no answers, maybe you guys can help.
>>
>> I am developing a stand-alone application for dynamically loading several
>> XMI files using EMF. Each file can refer to a different package - or
>> metamodel - (ex: uml2, gmf, or my own ecore metamodel), through a
>> different namespace in the xmi file. I've followed the EMF tutorial for
>> doing this, and it works fine:
>>
>> // Initialize the resource set.
>> ResourceSet resourceSet = new ResourceSetImpl();
>> // Register the default resource factory -- only needed for
>> stand-alone!
>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(
>> Resource.Factory.Registry.DEFAULT_EXTENSION, new
>> XMIResourceFactoryImpl());
>>
>> // Register the package
>> UMLPackage.eINSTANCE.eClass();
>>
>> URI fileURI = URI.createFileURI(file.getAbsolutePath());
>>
>> // Demand load the resource for this file.
>> Resource resource = resourceSet.getResource(fileURI, true);
>>
>> However, some of my files are use two different versions of the UML
>> metamodel (1.0.0 and 2.2.0). If I read them separately (two executions of
>> the main method), it works. However, if I try to load them in the same
>> execution (meaning that both metamodels - jar files - are loaded into the
>> JVM at the same time), there seems to be some conflict, and an exception
>> is thrown:
>>
>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
>> 'base_Activity' not found.
>> (file:/C:/eclipseWorkspace/StandaloneEMFTest/models/Sample1. uml, 667,
>> 103)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeatu re(XMLHandler.java:1856)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeatu re(XMLHandler.java:1820)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.handleUnknownFeatu re(XMIHandler.java:149)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XML Handler.java:2570)
>> at
>> org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAtt ribs(SAXXMIHandler.java:76)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2058)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1270)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1336)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:970)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:953)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:684)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
>> at
>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocume ntParser.emptyElement(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>> Source)
>> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>> Source)
>> at
>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>> Source)
>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:179)
>> at
>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1354)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1155)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:256)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:271)
>> at
>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:398)
>>
>> Maybe it's because some elements have the same name in the different
>> versions of UML, and EMF is getting lost. I am not sure about this. Also,
>> depending on the order I load the files, it works: If I load a UML 1.0.0
>> file first, it works, but if I load the UML 2.2.0 first, the error
>> occurs.
>>
>> What I want to do is to consider one metamodel at a time. For example:
>> while reading a file for UML 2.2.0, only the UML 2.2.0 package is loaded.
>> Then, I want to unload it, load another version of UML, and then read the
>> file, so that there won't be any conflicts.
>>
>> However, the only way of registering these packages is by accessing the
>> eINSTANCE field, which triggers some init() method that already loads the
>> classes into some kind of global registry, and I am unable to unload them
>> after that. Is there another way of registering the metamodel packages
>> other than by using the eINSTANCE field(), so that I can try to use some
>> custom class loader, for example, and have more control over which
>> classes are loaded?
>>
>> Thanks
>>
Re: metamodel conflict while reading xmi file [message #625230 is a reply to message #476394] Wed, 17 October 2007 16:36 Go to previous message
Miles Parker is currently offline Miles ParkerFriend
Messages: 1341
Registered: July 2009
Senior Member
Just a suggestion Daniel, but my thought is that you should first
convert to common representation, e.g. 1.0.0 to 2.2.0, before actually
loading them..

On 2007-10-17 06:24:08 -0700, "Kenn Hussey" <Kenn.Hussey@embarcadero.com> said:

> This appears to be a problem with profiles - the 'base_Activity'
> feature is most likely a reference from the Ecore representation of a
> stereotype to its metaclass.
>
> Note that specific options are required in order to successfully load a
> UML resource; these are turned on by default in the UML resource
> implementation, and I suspect the situtation is similar for other
> resource types... so I wouldn't recommend trying to load different
> resource types using the same resource implementation (i.e. the default
> XMI one).
>
> Kenn
>
> "Ed Merks" <merks@ca.ibm.com> wrote in message
> news:ff4r8i$aqi$1@build.eclipse.org...
>> Daniel,
>>
>> It seems to me that the UML2 project provides a specialized resource
>> factory that you should be using instead. So it's best to read the UML
>> documentation and ask questions about problems on the UML2 newsgroup,
>> which I've added to the "to" list of the reply.
>>
>> In general accessing XyzPackage.eINSTANCE.eClass() will register that
>> package in the EPackage.Registry.INSTANCE, but a resource set has a
>> local getPackageRegistry() and you can register things locally to hide
>> or augment the global registrations...
>>
>>
>> Daniel Lucredio wrote:
>>> Hi everybody, I've been looking for a solution for this, and I still
>>> found no answers, maybe you guys can help.
>>>
>>> I am developing a stand-alone application for dynamically loading
>>> several XMI files using EMF. Each file can refer to a different package
>>> - or metamodel - (ex: uml2, gmf, or my own ecore metamodel), through a
>>> different namespace in the xmi file. I've followed the EMF tutorial for
>>> doing this, and it works fine:
>>>
>>> // Initialize the resource set.
>>> ResourceSet resourceSet = new ResourceSetImpl();
>>> // Register the default resource factory -- only needed for stand-alone!
>>> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put(
>>> Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
>>>
>>> // Register the package
>>> UMLPackage.eINSTANCE.eClass();
>>>
>>> URI fileURI = URI.createFileURI(file.getAbsolutePath());
>>>
>>> // Demand load the resource for this file.
>>> Resource resource = resourceSet.getResource(fileURI, true);
>>>
>>> However, some of my files are use two different versions of the UML
>>> metamodel (1.0.0 and 2.2.0). If I read them separately (two executions
>>> of the main method), it works. However, if I try to load them in the
>>> same execution (meaning that both metamodels - jar files - are loaded
>>> into the JVM at the same time), there seems to be some conflict, and an
>>> exception is thrown:
>>>
>>> org.eclipse.emf.ecore.xmi.FeatureNotFoundException: Feature
>>> 'base_Activity' not found.
>>> (file:/C:/eclipseWorkspace/StandaloneEMFTest/models/Sample1. uml, 667,
>>> 103)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.reportUnknownFeatu re(XMLHandler.java:1856)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleUnknownFeatu re(XMLHandler.java:1820)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.handleUnknownFeatu re(XMIHandler.java:149)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XML Handler.java:2570)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAtt ribs(SAXXMIHandler.java:76)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFa ctory(XMLHandler.java:2058)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1270)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1336)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:970)
at
>>>
>>> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMI Handler.java:87)
>>> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:953)
>>> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:684)
>>> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHa ndler.java:167)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocume ntParser.emptyElement(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown
>>> Source)
>>> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown Source)
>>> at
>>> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown
>>> Source)
>>> at
>>> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown
>>> Source)
>>> at javax.xml.parsers.SAXParser.parse(Unknown Source)
>>> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:179)
>>> at
>>> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at
>>>
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1354)
>>> at
>>> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1155)
at
>>>
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:256)
at
>>>
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:271)
at
>>>
>>> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:398)

Maybe
>>>
>>> it's because some elements have the same name in the different versions
>>> of UML, and EMF is getting lost. I am not sure about this. Also,
>>> depending on the order I load the files, it works: If I load a UML
>>> 1.0.0 file first, it works, but if I load the UML 2.2.0 first, the
>>> error occurs.
>>>
>>> What I want to do is to consider one metamodel at a time. For example:
>>> while reading a file for UML 2.2.0, only the UML 2.2.0 package is
>>> loaded. Then, I want to unload it, load another version of UML, and
>>> then read the file, so that there won't be any conflicts.
>>>
>>> However, the only way of registering these packages is by accessing the
>>> eINSTANCE field, which triggers some init() method that already loads
>>> the classes into some kind of global registry, and I am unable to
>>> unload them after that. Is there another way of registering the
>>> metamodel packages other than by using the eINSTANCE field(), so that I
>>> can try to use some custom class loader, for example, and have more
>>> control over which classes are loaded?
>>>
>>> Thanks
Previous Topic:uml2 genmodel, abstract classes and operations
Next Topic:Profile'.getDefinition inverse? Ecore2UML
Goto Forum:
  


Current Time: Fri Apr 19 01:10:55 GMT 2024

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

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

Back to the top