Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Reading .emx model file(Error during file parsing)
Reading .emx model file [message #1782313] Wed, 21 February 2018 16:10 Go to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
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 211 times)

[Updated on: Wed, 21 February 2018 16:11]

Report message to a moderator

Re: Reading .emx model file [message #1782315 is a reply to message #1782313] Wed, 21 February 2018 16:34 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi Dmitrii,

Did you try to install the Papyrus / RSA Interop plug-ins? They provide all the features required to read *.emx/*.epx/*.efx models (Including the namespace declarations), plus some diagram conversion features (For the main diagrams)

Cheers,
Camille


Camille Letavernier
Re: Reading .emx model file [message #1782346 is a reply to message #1782315] Thu, 22 February 2018 09:28 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Hi Camille,

I forgot to mention that I am trying to implement reading .emx model as standalone java application in IntelliJ. Is there such a plugin for IntelliJ? Can you share a link for the plugins that you mentioned? Thanks!

Re: Reading .emx model file [message #1782350 is a reply to message #1782346] Thu, 22 February 2018 09:51 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
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


Camille Letavernier
Re: Reading .emx model file [message #1782373 is a reply to message #1782350] Thu, 22 February 2018 12:55 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Hi Camille,

org.eclipse.papyrus.interoperability.rsa jar is the first one in my dependency list in java project and this is the module I started from. Basically, I tried to reproduce import of RSA-RTE model (org.eclipse.papyrus.interoperability.rsa.wizard.TransformationWizard and org.eclipse.papyrus.interoperability.rsa.transformation.ImportTransformationLauncher) as a standalone application but I faced some problems (described here).

That is why I am trying to implement the reading of the .emx model file from scratch. I checked the stacktrace and implementation of the Connector element and I concluded that for the field "kind" one of the valid values is "assembly", but the exception says the opposite. So, I was thinking may be somebody already knows how to solve this issue or at least what is the real problem.

As you can see from my first post in a few lines I am including missing nsURI's, which I indeed got partially from C:\GIT\org.eclipse.papyrus-interoperability\rsa\plugins\org.eclipse.papyrus.interoperability.rsa\plugin.xml file. What about content type declarations? Where can I get it?

This is my dependancy list:
https://i.imgur.com/H0eOLFT.png

Not everything is used right now but like I said I am trying different ways.

Thank you for your help!






Re: Reading .emx model file [message #1782377 is a reply to message #1782373] Thu, 22 February 2018 13:11 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
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


Camille Letavernier
Re: Reading .emx model file [message #1782381 is a reply to message #1782377] Thu, 22 February 2018 14:27 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Hi,

Why in this case in Papyrus-RT import RSA model it uses MigrationResourceSetImpl? Shouldn't I use the same?

protected void initResourceSet(IProgressMonitor monitor) {
		resourceSet = new MigrationResourceSetImpl(analysisHelper);
		synchronized (UMLUtil.class) {
			UMLUtil.init(resourceSet);
		}
		resourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_ATTACHMENT, true);
		resourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true);
		resourceSet.getLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
		resourceSet.getLoadOptions().put(XMLResource.OPTION_USE_PACKAGE_NS_URI_AS_LOCATION, Boolean.FALSE);

		monitor.subTask("Loading source model " + getModelName());

		try {
			resourceSet.getResource(sourceURI, true);
			loadInPapyrusProfiles();
		} catch (Exception ex) {
			Activator.log.error("An error occurred while loading " + getModelName(), ex);
		}
	}
Re: Reading .emx model file [message #1782382 is a reply to message #1782381] Thu, 22 February 2018 14:41 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi,

This specific resource-set doesn't provide any additional value wrt. resource loading, compared to the standard EMF ResourceSetImpl. It simply provides some extra feature to support multi-threaded conversion (EMF is not thread-safe)

The UMLUtil.init() and load option configurations may still help, but they work exactly the same with a standard ResourceSetImpl

Regards,
Camille


Camille Letavernier
Re: Reading .emx model file [message #1782383 is a reply to message #1782381] Thu, 22 February 2018 14:42 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
After changing factory to UML302UMLResourceFactoryImpl, I get the following error:
Exception in thread "main" org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: java.net.MalformedURLException: unknown protocol: platform
	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 org.eclipse.uml2.uml.internal.resource.UML302UMLResourceFactoryImpl.createResource(UML302UMLResourceFactoryImpl.java:95)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.createResource(ResourceSetImpl.java:434)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandCreateResource(ResourceSetImpl.java:243)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:400)
	at RSAModelParser.main(RSAModelParser.java:97)
Caused by: java.net.MalformedURLException: unknown protocol: platform
	at java.net.URL.<init>(URL.java:600)
	at java.net.URL.<init>(URL.java:490)
	at java.net.URL.<init>(URL.java:439)
	at org.eclipse.emf.ecore.resource.impl.URIHandlerImpl.createInputStream(URIHandlerImpl.java:199)
	at org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl.createInputStream(ExtensibleURIConverterImpl.java:360)
	at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1269)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoad(ResourceSetImpl.java:259)
	at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
	... 6 more

Process finished with exit code 1


As far as I understand a problem appears here :
ecore2xmlRegistry.put("http://www.eclipse.org/uml2/3.0.0/UML", EcoreUtil.getObjectByType(resourceSet.getResource(URI.createURI("platform:/plugin/org.eclipse.uml2.uml/model/UML30_2_UML.ecore2xml"), true).getContents(), Literals.XML_MAP));

in UML302UMLResourceFactoryImpl.java

[Updated on: Thu, 22 February 2018 15:22]

Report message to a moderator

Re: Reading .emx model file [message #1782391 is a reply to message #1782383] Thu, 22 February 2018 16:06 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
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 16:07]

Report message to a moderator

Re: Reading .emx model file [message #1782394 is a reply to message #1782391] Thu, 22 February 2018 16:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Initializing UML for standalone usage used to be a nightmare, particularly for legacy functionality. The UMLResourcesUtil.init() functionality solves this.

I recommend ensuring that whatever is necessary to make this work with IntelliJ is done. Your code should not mention any UML version specific classes such as UML302UMLResource.

Regards

Ed Willink

Re: Reading .emx model file [message #1782426 is a reply to message #1782394] Fri, 23 February 2018 07:58 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
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


Camille Letavernier
Re: Reading .emx model file [message #1782428 is a reply to message #1782426] Fri, 23 February 2018 08:59 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Yes. UMLResourcesUtil.init() won't register *.emx, but it will register everything to do with UML in particular all the content types that allow multiple dialects for the one *.uml extension.

Playing with the attached PingPong.emx, it appears to be a standard *.uml file with a http://www.eclipse.org/uml2/3.0.0/UML namespace, and embedded graphical eAnnotations. Once I change the extension to *.uml, the UML Editor is happy to load it, within the limits of not having any of the imported declarations.

It should be sufficient to 'clone' every line in UMLResourcesUtil.init() that has a *.uml to something functionality to do the same for *.emx. Alternatively just rename everything to *.uml.

( UMLResourcesUtil.init() is the result of my struggles with the draft UML 2.5 models. It took a long time to resurrect the original UML 2.1/2.2 flexibility that had not been fully considered by UML 2.4 support and avoid all declarations needing to be provided by super-expert users. Exploit it, don't try to rediscover it.)

---

Errors such as "Value 'assembly' is not legal." are often the result of using the wrong UML dialect. I suspect that standalone you are using UML 2.5 since the http://www.eclipse.org/uml2/3.0.0/UML namespace has not influenced the UMLResource construction.


You can create a miniature *.uml model with just the offending property in, and play with the xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" to confirm this within Eclipse.

Regards

Ed Willink
Re: Reading .emx model file [message #1782445 is a reply to message #1782426] Fri, 23 February 2018 14:46 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Hi Camille,

I get UML302UMLResourceImpl

Regards,
Dmitrii
Re: Reading .emx model file [message #1782541 is a reply to message #1782445] Mon, 26 February 2018 10:23 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
What about UMLRealTimeResourceFactoryImpl()? Why I cannot use this one?
Re: Reading .emx model file [message #1782562 is a reply to message #1782541] Mon, 26 February 2018 13:45 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Well I don't really know what happened but it works now:

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.uml2.uml.internal.resource.UMLResourceFactoryImpl;


public class RSAModelParser {

    public static void main(String[] args){
        URI modelFileURI = URI.createFileURI("C:/Users/"+System.getProperty("user.name")+"/Desktop/PingPong.emx");
            ResourceSet resourceSet = new ResourceSetImpl();
            resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("emx", new UMLResourceFactoryImpl());
            Resource resource = resourceSet.getResource(modelFileURI, true);
    }
}


Even with .emx extension. I just changed the previous resource factory to UMLResourceFactoryImpl.

Re: Reading .emx model file [message #1783379 is a reply to message #1782562] Mon, 12 March 2018 14:00 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Hi,

For now, I am having resource with all the elements from the file. When I say resource.getContents() I get a list of AnyTypeImpl objects. How can I transform all the objects according to their actual name? For instance, first element should be Package and last one should be RTConnector.
https://i.imgur.com/5OYwWvo.png

I tried to do the same as in StandaloneUMLRTCodeGenerator:
EList<EObject> contents = resource.getContents();
		org.eclipse.uml2.uml.Package pkg = (org.eclipse.uml2.uml.Package) EcoreUtil.getObjectByType(contents, UMLPackage.Literals.PACKAGE);


But it does not work, apparently because AnyTypeImpl is not a Package.
Re: Reading .emx model file [message #1783380 is a reply to message #1783379] Mon, 12 March 2018 14:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

AnyType is EMF's fallback for when it's all gone hopelessly wrong.

Your registrations are clearly a mess. Get them right and it should load properly.

Regards

Ed Willink
Re: Reading .emx model file [message #1783395 is a reply to message #1783380] Mon, 12 March 2018 15:19 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Dear Ed,

Can you be more clear please? I don't know about EMF as much as you do, this is the reason why I'm here.

For example, you said: "You can create a miniature *.uml model with just the offending property in, and play with the xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" to confirm this within Eclipse." - what do you mean by saying play?

In the last message - what registration are you talking about? Like this:
packageRegistry.put("http://www.eclipse.org/uml2/3.0.0/UML", UMLPackage.eINSTANCE);
?

Am I using the right resource set and the resource factory?
Thanks!

Regards,
Dmitrii Nikeshkin
Re: Reading .emx model file [message #1783399 is a reply to message #1783395] Mon, 12 March 2018 15:31 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
After changing the xmlns:uml="http://www.eclipse.org/uml2/3.0.0/UML" to xmlns:uml="http://www.eclipse.org/uml2/2.5.0/UML" and having the following code:
public static void main(String[] args) {
        URI modelFileURI = URI.createFileURI("C:/Users/" + System.getProperty("user.name") + "/Desktop/PingPong.uml");
//        URI modelFileURI = URI.createFileURI("C:/Users/" + System.getProperty("user.name") + "/Desktop/PingPong_Cut.uml");
        ResourceSet resourceSet = new ResourceSetImpl();
        UMLResourcesUtil.init(resourceSet);
        resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("uml", new UMLResourceFactoryImpl());
        Resource resource = resourceSet.getResource(modelFileURI, true);
    }


I don't get the "Value 'assembly' is not legal." error but resource.getContents() is still full of AnyTypeImpl objects.

The same goes to the "cut" version of the attached model before.

You can find "cut" version in the attachment.

[Updated on: Mon, 12 March 2018 15:33]

Report message to a moderator

Re: Reading .emx model file [message #1783403 is a reply to message #1783399] Mon, 12 March 2018 16:31 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
No Message Body
Re: Reading .emx model file [message #1783404 is a reply to message #1783403] Mon, 12 March 2018 16:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you provide a complete example I'll try to make time to have a look, but sorry I do not have time to study fragments.

Regards

Ed Willink
Re: Reading .emx model file [message #1783440 is a reply to message #1783404] Tue, 13 March 2018 08:02 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Hi Ed,

In the attachment you can find the complete example of the model. The source code I already provided above. Thanks a lot for your help and time!

Regards,
Dmitrii Nikeshkin
  • Attachment: PingPong.emx
    (Size: 59.16KB, Downloaded 193 times)

[Updated on: Tue, 13 March 2018 08:03]

Report message to a moderator

Re: Reading .emx model file [message #1783441 is a reply to message #1783440] Tue, 13 March 2018 08:27 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Sorry. Where is the .classpath / MANIFEST.MF / ... ? A complete example can be imported as a project from ZIP avoiding any guessing at what you actually did (wrong).

Regards

Ed Willink
Re: Reading .emx model file [message #1783445 is a reply to message #1783441] Tue, 13 March 2018 09:24 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Sorry, I thought .emx file is enough. Here is in the attachment you can find the whole project. But there is no .classpath or MANIFEST.MF I think because it is RSA-RTE project.

I also provided the whole java project that I use as test environment. It's called RSAModel. It is maven project made in IntelliJ. I don't really use maven because of proxy settings at my office. So, I add all the dependencies manually as jar from papyrus-rt.

Regards,
Dmitrii
  • Attachment: PingPong.zip
    (Size: 8.72KB, Downloaded 87 times)
  • Attachment: RSAModel.zip
    (Size: 2.53MB, Downloaded 87 times)
Re: Reading .emx model file [message #1783452 is a reply to message #1783445] Tue, 13 March 2018 10:04 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

This is an Eclispe forum where you may receive help on Eclipse projects, not IntelliJ or RSA.

You need to convert your problem into an Eclipse one. You should be aware from the earlier replies that UMLResourcesUtil.init() is very important to getting your registrations right.

Once you have solved your problem within Eclipse, or presented something to allow someone to help you solve it within Eclipse, you may then have a suitable oracle for contrasting what malfunctions in other environments.

Regards

Ed Willink
Re: Reading .emx model file [message #1783453 is a reply to message #1783452] Tue, 13 March 2018 10:24 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
For the eclipse project, it is expectedly the same. (the project in the attachment)
Re: Reading .emx model file [message #1783455 is a reply to message #1783453] Tue, 13 March 2018 10:35 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
For the convenience I moved all the dependencies and model files to the project folder, so please use this one:
Re: Reading .emx model file [message #1783463 is a reply to message #1783455] Tue, 13 March 2018 11:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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 #1783490 is a reply to message #1783463] Tue, 13 March 2018 15:08 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
I cannot just take off the part of the model and say "It works". I believe that the problem is in dependencies/profiles. That's how this model file should be parsed:
https://i.imgur.com/dKA2pi9.png

The screenshot above is made by debugging PapyrusRT import. I am trying to reach the same. I believe that it is possible without extending and changing classes, because Papyrus-RT can do this already. It uses org.eclipse.papyrus.interoperability.rsa.transformation.DependencyAnalysisHelper to solve all the dependencies and loads my model perfectly (creates list of the objects according to the .emx file elements).

I know that I can solve the problem by extending classes, process each problem situation, but this is something that I am trying to avoid, because I don't want to reinvent a wheel.
Re: Reading .emx model file [message #1783491 is a reply to message #1783490] Tue, 13 March 2018 15:20 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
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
Previous Topic:Get and create SysML subprofiles (SysML 1.4 Memtamodel)
Next Topic:Basic way to create custom palettes
Goto Forum:
  


Current Time: Fri Apr 19 23:11:33 GMT 2024

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

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

Back to the top