Cannot read module from ATL EMFTVM transformation in Java standalone project

398 Views Asked by At

According to the ATL/EMFTVM wiki, ATL/EMFTVM can be run standalone by using

ResourceSet moduleRS = new ResourceSetImpl();
moduleRS.getResourceFactoryRegistry().getExtensionToFactoryMap().put(Resource.Factory.Registry.DEFAULT_EXTENSION, new XMIResourceFactoryImpl());

DefaultModuleResolver mr = new DefaultModuleResolver("pathToModuleDirectory", moduleRS);
TimingData td = new TimingData();
env.loadModule(mr, "ModuleName");
td.finishLoading();
env.run(td);
td.finish();

However, this always yields an exception saying Module not found. I debugged the code into great detail. Internally, a SaxParseException is thrown, which is weird since my .emftvm file is not a XML file. Any ideas how I can load the file properly? Thanks in advance!

2

There are 2 best solutions below

2
On

I got the old version of EMFTVM, and have the same problem as you. I pull the latest version from github, and it is fine now.

Updates: @dwagelaar, aha, yes, I used EMFTVMResourceFactoryImpl; Here is the code I used btw:

    ExecEnv env = EmftvmFactory.eINSTANCE.createExecEnv();
    ResourceSet rs = new ResourceSetImpl();
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
    rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put("emftvm", new EMFTVMResourceFactoryImpl());

Also, instead of passing a new ResourceSetImpl(as indicated in Wiki),

// Don't do this! 
ModuleResolver mr = new DefaultModuleResolver("platform:/plugin/my.plugin.id/transformations/", new ResourceSetImpl());

I passed in the rs object initialized above.

1
On

This (still) does not work, because you would have to tell EMF that *.emftvm files are not XMI, and require the EMFTVMResourceFactoryImpl. The ATL/EMFTVM wiki page has been updated with improved code; see: https://wiki.eclipse.org/ATL/EMFTVM#Standalone_use