Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Cross-references in EMFTVM VM standalone
Cross-references in EMFTVM VM standalone [message #1745944] Wed, 19 October 2016 17:14 Go to next message
Antonio Moreno is currently offline Antonio MorenoFriend
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 &lt;AComponent> &lt;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 Go to previous messageGo to next message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 357
Registered: September 2012
Location: Belgium
Senior Member

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 Go to previous messageGo to next message
Antonio Moreno is currently offline Antonio MorenoFriend
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

Re: Cross-references in EMFTVM VM standalone [message #1750919 is a reply to message #1746631] Sun, 01 January 2017 23:47 Go to previous messageGo to next message
Dat Nguyen is currently offline Dat NguyenFriend
Messages: 32
Registered: July 2014
Member
No Message Body

[Updated on: Mon, 02 January 2017 23:24]

Report message to a moderator

Re: Cross-references in EMFTVM VM standalone [message #1750920 is a reply to message #1746631] Sun, 01 January 2017 23:48 Go to previous message
Dat Nguyen is currently offline Dat NguyenFriend
Messages: 32
Registered: July 2014
Member


[Updated on: Mon, 02 January 2017 23:25]

Report message to a moderator

Previous Topic:ATL transformation rules not matching nested BPMN2 elements
Next Topic:Tranformation Question ( KDM Model to JAVA Model)
Goto Forum:
  


Current Time: Mon Jan 22 20:34:01 GMT 2018

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

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