Cross-references in EMFTVM VM standalone [message #1745944] |
Wed, 19 October 2016 17:14 |
Antonio Moreno Messages: 16 Registered: November 2012 |
Junior Member |
|
|
Hi,
I am running an ATL transformation from Java inside an Eclipse plug-in using the EMFTVM VM.
As input models I have several models with cross references as it is shown in the last line
of this code:
<allocation:Allocation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI"xmlns:allocation="http://sdq.ipd.uka.de/PalladioComponentModel/Allocation/5.0" id="_JiPBICHdEd6lJo4DCALHMw" entityName="defaultAllocation">
<targetResourceEnvironment_Allocation href="My.resourceenvironment#/"/>
<system_Allocation href="default.system#_84D0kCHcEd6lJo4DCALHMw"/>
<allocationContexts_Allocation id="_KCkHACHdEd6lJo4DCALHMw" entityName="Allocation_Assembly_AComponent <AComponent> <AComponent>">
<resourceContainer_AllocationContext href="My.resourceenvironment#_B0aZ0CHdEd6lJo4DCALHMw"/>
...
(note the last line how the attribute is set by a proxy to another file in the same path)
When I run this transformation using the "Run Configuration" in Eclipse, it works fine. However when I triggered the transformation for the same inputs from Java, it fails. The error it throws is the one shown when the proxies/cross-references are not resolved:
org.eclipse.m2m.atl.emftvm.util.VMException: java.lang.ClassCastException: The value of type 'org.eclipse.emf.ecore.impl.EClassImpl@bf33f92 (name: BasicComponent) (instanceClassName: null) (abstract: false, interface: false)' must be of type 'org.eclipse.emf.ecore.impl.EClassImpl@3ab1a290 (name: PCMrepositoryRepositoryComponent) (instanceClassName: null) (abstract: true, interface: false)'
at rule FlattenAssemblyContext@postApply#4(platform:/plugin/es.uma.lcc.e-motions/transformations/MM2FlattenMM.atl#[373:4-373:109])
Local variables: [__trace__: TRACE!TraceLink = 3d52cf4:TRACE!TraceLink, sourceClass: PCM!AssemblyContext = _9c3KwCHcEd6lJo4DCALHMw:PCM!AssemblyContext, targetClass: FlattenPCM!PCMcompositionAssemblyContext = _9c3KwCHcEd6lJo4DCALHMw:FlattenPCM!PCMcompositionAssemblyContext]
at static EMFTVM!ExecEnv::main() : Object(platform:/plugin/es.uma.lcc.e-motions/transformations/MM2FlattenMM.atl)
I am loading the models as follows:
Model inPrimitiveTypes = EmftvmFactory.eINSTANCE.createModel();
inPrimitiveTypes.setResource(rs.getResource(URI.createFileURI(fileManager.getNewPalladioRepository().getFullPath().toOSString()), true));
env.registerInputModel("INPRIMITIVETYPES", inPrimitiveTypes);
...
EcoreUtil.resolveAll(rs);
Where "fileManager.getNewPalladioRepository()" is an "IFile" and all the input models are in the same folder, as they are if they are run using the Run Configuration.
Also I am doing the "resolveAll"... just in case.
Any hint?
Full code is here:
https://github.com/e-motions/e-motions_plugin/blob/master/e-motions_plugin/src/es/uma/lcc/e_motions/jobs/PalladioJob.java#L95
Thank you very much in advance.
[Updated on: Thu, 27 October 2016 14:48] Report message to a moderator
|
|
|
Re: Cross-references in EMFTVM VM standalone [message #1746609 is a reply to message #1745944] |
Tue, 01 November 2016 16:58 |
|
That error looks like a metamodel aliasing bug, where the same ecore file is loaded more than once. Looking at your code, you're loading your ecore files by OS path multiple times. However, the registerMetamodel() only works for namespace URIs, not file URIs. If you follow this pattern, you MUST load your metamodels later by namespace URI, not their filesystem path.
Cheers,
Dennis
|
|
|
Re: Cross-references in EMFTVM VM standalone [message #1746631 is a reply to message #1746609] |
Wed, 02 November 2016 09:49 |
Antonio Moreno Messages: 16 Registered: November 2012 |
Junior Member |
|
|
Finally solved this issue with some help by e-mail. Thanks Dennis, Jesús and Steffen.
The problem was that the models where loaded with relative paths:
inUsageModel.setResource(rs.getResource(URI.createFileURI(fileManager.getNewUsageModel().getFullPath().toOSString()), true));
instead of absolute path
inUsageModel.setResource(rs.getResource(URI.createFileURI(fileManager.getNewUsageModel().getLocation().toOSString()), true));
With this modification models are loaded with absolute path and cross-references can be resolved.
Thank you all!
Antonio
[Updated on: Wed, 02 November 2016 09:50] Report message to a moderator
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04262 seconds