Home » Modeling » Papyrus » Reading .emx model file(Error during file parsing)
Reading .emx model file [message #1782313] |
Wed, 21 February 2018 11:10  |
Eclipse User |
|
|
|
Hi,
I am trying to read .emx model file that contains RSA-RTE model with PingPong example, by doing:
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("emx", new XMIResourceFactoryImpl());
EPackage.Registry.INSTANCE.put("http://www.eclipse.org/uml2/3.0.0/UML", UMLPackage.eINSTANCE);
resourceSet.getPackageRegistry().put("http://www.ibm.com/xtools/1.5.3/Umlnotation", UmlnotationPackage.eINSTANCE);
resourceSet.getPackageRegistry().put("http:///schemas/Default/_fNm3AAqoEd6-N_NOT9vsCA/2", DefaultPackage.eINSTANCE);
resourceSet.getPackageRegistry().put("http:///schemas/UMLRealTime/_3TUzoHq6Ed2hSeAAWZznoA/119", UMLRealTimePackage.eINSTANCE);
Resource resource = resourceSet.getResource(modelFileURI, true);
And I get the following error:
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'assembly' is not legal. (file:/C:/Users/qdni/Desktop/PingPong.emx, 530, 105)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at RSAModelParser.main(RSAModelParser.java:93)
Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'assembly' is not legal. (file:/C:/Users/qdni/Desktop/PingPong.emx, 530, 105)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2697)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XMLHandler.java:2751)
at org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAttribs(SAXXMIHandler.java:79)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFactory(XMLHandler.java:2229)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFeatureType(XMLHandler.java:2195)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:2071)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHandler.java:151)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1876)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1030)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:82)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:190)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1359)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
... 2 more
Caused by: java.lang.IllegalArgumentException: The feature 'kind' is not a valid changeable feature
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenSet(BasicEObjectImpl.java:1141)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl.java:1119)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl.java:1112)
at org.eclipse.uml2.uml.internal.impl.ConnectorImpl.eSet(ConnectorImpl.java:519)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1071)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1156)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2692)
... 31 more
Any ideas how to fix this problem? Emx model is correct. Here in the attachment you can find the model. Thanks!
Attachment: PingPong.emx
(Size: 59.20KB, Downloaded 236 times)
[Updated on: Wed, 21 February 2018 11:11] by Moderator
|
|
| | |
Re: Reading .emx model file [message #1782350 is a reply to message #1782346] |
Thu, 22 February 2018 04:51   |
Eclipse User |
|
|
|
Hi Dmitrii,
The plug-in probably wouldn't be immediately compatible with IntelliJ, as it contains some eclipse extensions. However, it might be a good starting point to see how we achieved this in Papyrus
You can find the sources here: https://git.eclipse.org/c/gerrit/papyrus/org.eclipse.papyrus-interoperability.git/tree/rsa/plugins/org.eclipse.papyrus.interoperability.rsa
You can also install it in Eclipse via the following update site: http://download.eclipse.org/modeling/mdt/papyrus/interoperability/rsa
As mentioned earlier, this plug-in covers several aspects required for importing RSA-RTE models in Papyrus. The first step was to be able to read the *.emx models, which is achieved via custom Ecore metamodels and adding specific content-types, so that Eclipse/UML2 can recognize these models as UML2.3 models (And migrate them to UML2.5). This is probably the part that you'd want to reuse.
So you'd need:
- The ecore metamodels used to understand what's inside an *.emx file: all *.ecore models in the /model/ folder
- The nsURI declarations to map these Ecore models to the RSA nsURIs: this is done in plugin.xml via Eclipse Extension Points, so you'll need something equivalent in plain-Java
- The content type declarations, so UML can detect that *.emx files are actually UML2.3 models (Older versions of UML need to be opened with special handlers, because they are not 100% compatible with UML 2.5). Once again, this is done in the plugin.xml, so you'll need to redeclare this in Java
IIRC, these should be the only required items to read *.emx files (Everything else in that plug-in is related to migrating the diagrams to the Papyrus format)
HTH,
Camille
|
|
| |
Re: Reading .emx model file [message #1782377 is a reply to message #1782373] |
Thu, 22 February 2018 08:11   |
Eclipse User |
|
|
|
Hi,
For the exception itself, I believe (I'm pretty sure) that it is because the *.emx file is not loaded in a 'UML302UMLResourceImpl' Resource (The resource that is responsible for converting UML2 3.x models - used by RSA - to UML2 5.x - used by Papyrus).
This resource should be instantiated by the 'UML302UMLResourceFactoryImpl' ResourceFactory, which should be associated to *.emx models
I'm not sure how to associate ContentTypes programmatically, but trying to debug the resource-instantiation steps should help (If you get a UMLResourceImpl or XMIResourceImpl instead of UML302UMLResourceImpl, then the model won't be properly loaded and will throw such exceptions)
An easy (Although a little bit "over-simplified") way to make sure you're using the correct factory would be to use:
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("emx", new UML302UMLResourceFactoryImpl());
instead of:
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("emx", new XMIResourceFactoryImpl());
(This is over-simplified, because it wouldn't work with older versions of RSA Models, using e.g. UML2.2)
HTH,
Camille
|
|
| | | |
Re: Reading .emx model file [message #1782391 is a reply to message #1782383] |
Thu, 22 February 2018 11:06   |
Eclipse User |
|
|
|
Well after roughly changing
Ecore2XMLRegistry ecore2xmlRegistry = new Ecore2XMLRegistryImpl(
Ecore2XMLRegistry.INSTANCE);
ecore2xmlRegistry
.put(
UML302UMLResource.UML_METAMODEL_NS_URI,
EcoreUtil
.getObjectByType(
resourceSet
.getResource(
URI
.createURI("platform:/plugin/org.eclipse.uml2.uml/model/UML30_2_UML.ecore2xml"), //$NON-NLS-1$
true).getContents(),
Ecore2XMLPackage.Literals.XML_MAP));
to
Ecore2XMLRegistry ecore2xmlRegistry = new Ecore2XMLRegistryImpl(
Ecore2XMLRegistry.INSTANCE);
ecore2xmlRegistry
.put(
UML302UMLResource.UML_METAMODEL_NS_URI,
EcoreUtil
.getObjectByType(
resourceSet
.getResource(
URI
.createURI(ClassLoader.getSystemResource("./model/UML30_2_UML.ecore2xml").toString()), //$NON-NLS-1$
true).getContents(),
Ecore2XMLPackage.Literals.XML_MAP));
where the "model" folder is the same folder copied to the project's "resource" folder I am getting the same error
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'assembly' is not legal. (file:/C:/Users/qdni/Desktop/PingPong.emx, 530, 105)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:278)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:406)
at RSAModelParser.main(RSAModelParser.java:100)
Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'assembly' is not legal. (file:/C:/Users/qdni/Desktop/PingPong.emx, 530, 105)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2697)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setAttribValue(XMLHandler.java:2751)
at org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler.handleObjectAttribs(SAXXMIHandler.java:79)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFactory(XMLHandler.java:2229)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectFromFeatureType(XMLHandler.java:2195)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObject(XMLHandler.java:2071)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.createObject(XMIHandler.java:151)
at org.eclipse.uml2.uml.internal.resource.UML302UMLHandler.createObject(UML302UMLHandler.java:67)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.handleFeature(XMLHandler.java:1850)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1030)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:82)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:190)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1359)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2784)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:602)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:505)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:841)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:770)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:643)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl.parse(SAXParserImpl.java:327)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:261)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
... 2 more
Caused by: java.lang.IllegalArgumentException: The feature 'kind' is not a valid changeable feature
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eOpenSet(BasicEObjectImpl.java:1141)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl.java:1119)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eDynamicSet(BasicEObjectImpl.java:1112)
at org.eclipse.uml2.uml.internal.impl.ConnectorImpl.eSet(ConnectorImpl.java:519)
at org.eclipse.emf.ecore.impl.BasicEObjectImpl.eSet(BasicEObjectImpl.java:1071)
at org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl.setValue(XMLHelperImpl.java:1156)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.setFeatureValue(XMLHandler.java:2692)
... 32 more
Process finished with exit code 1
I will continue investigating how I can read the model in standalone application. Any help is appreciated.
[Updated on: Thu, 22 February 2018 11:07] by Moderator
|
|
| |
Re: Reading .emx model file [message #1782426 is a reply to message #1782394] |
Fri, 23 February 2018 02:58   |
Eclipse User |
|
|
|
Hi Ed,
By default, UML Initialization won't recognize *.emx files, no matter what (Because UML content types, which are used to determine which resource class should be instantiated, are only associated with *.uml, *.xmi and a few other standard file extensions).
So UMLResourcesUtil.init() may help but definitely won't be sufficient
@Dmitrii: did you check which Resource instance you get at runtime? If you get a UML302UMLResourceImpl, then this is probably a UML bug (The correct resource doesn't behave as expected). If you get any other resource instance, then the UML ContentTypes/Factories are not properly configured, and you should keep investigating that
Regards,
Camille
|
|
| | | | | | | | | | | | | | | | |
Re: Reading .emx model file [message #1783463 is a reply to message #1783455] |
Tue, 13 March 2018 07:14   |
Eclipse User |
|
|
|
Hi
Once you change the erroneous xmlns:uml="http://www.eclipse.org/uml2/2.5.0/UML" to xmlns:uml="http://www.eclipse.org/uml2/2.0.0/UML", your reader loads the Eclipse UML to give:
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'assembly' is not legal. (file:///E:/Development/Rusa/Workspace/PingPongREader/models/PingPong.uml, 530, 105)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:319)
...
Caused by: org.eclipse.emf.ecore.xmi.IllegalValueException: Value 'assembly' is not legal. (file:///E:/Development/Rusa/Workspace/PingPongREader/models/PingPong.uml, 530, 105)
...
Caused by: java.lang.IllegalArgumentException: The feature 'kind' is not a valid changeable feature
Checking the UML 2.3 and 2.5 specs, the Connector::kind feature is derived, so it should not be serialized in the UML file. After deleting the erroneous element, the model loads in your program. The first resource content is a PackageImpl tree. The remainder are AnyTypeImpl which is the fallback for stereotype applications for which there is no official UML element. In the UML Model Editor, the missing libraries cause three errors.
If editing your source model is impractical, you can fix the 'bug' which oocurs at
Thread [main] (Suspended (exception IllegalArgumentException))
ConnectorImpl(BasicEObjectImpl).eOpenSet(EStructuralFeature, Object) line: 1141
ConnectorImpl(BasicEObjectImpl).eDynamicSet(int, EStructuralFeature, Object) line: 1119
ConnectorImpl(BasicEObjectImpl).eDynamicSet(int, Object) line: 1112
ConnectorImpl.eSet(int, Object) line: 519
ConnectorImpl(BasicEObjectImpl).eSet(EStructuralFeature, Object) line: 1071
XMIHelperImpl(XMLHelperImpl).setValue(EObject, EStructuralFeature, Object, int) line: 1156
UMLHandler(XMLHandler).setFeatureValue(EObject, EStructuralFeature, Object, int) line: 2710
UMLHandler(XMLHandler).setAttribValue(EObject, String, String) line: 2769
by providing a derived UMLResourceFactoryImpl that provides a derived UMLHandler that overrides setFeatureValue for the specific case of Connectior::kind or the generic case of setting a derived feature.
Regards
Ed Willink
|
|
| |
Re: Reading .emx model file [message #1783491 is a reply to message #1783490] |
Tue, 13 March 2018 11:20  |
Eclipse User |
|
|
|
Hi
I'm sorry, I really have no idea what you are trying to do.
If you give me a repro I can debug it. If you just assert that it could work, then why doesn't it? If something else works then use two debuggers to see where it deviates.
Regards
Ed Willink
|
|
|
Goto Forum:
Current Time: Wed Jul 23 13:48:44 EDT 2025
Powered by FUDForum. Page generated in 0.11250 seconds
|