我尝试从java-app以编程方式启动ATL / EMFTVM转换。在模块加载时(execEnv.loadModule(mr,“moduleName”)),在模块加载期间发生异常报告错误:未找到元模型输入。
一段代码:
ModuleResolver mr = new DefaultModuleResolver(transformationDir, resourceSet);
TimingData td = new TimingData();
execEnv.loadModule(mr, "moduleName");
td.finishLoading();
env.run(td);
td.finish();
例外:
Exception in thread "main" org.eclipse.m2m.atl.emftvm.util.VMException: Error during module loading: Metamodel input not found
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.loadModule(ExecEnvImpl.java:1265)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.loadModule(ExecEnvImpl.java:1217)
at ATLLauncher.launch(ATLLauncher.java:102)
at ServiceRunner.main(ServiceRunner.java:65)
Caused by: java.lang.IllegalArgumentException: Metamodel input not found
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.findType(ExecEnvImpl.java:2061)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.findEClassifier(ExecEnvImpl.java:2141)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.registerFeature(ExecEnvImpl.java:1316)
at org.eclipse.m2m.atl.emftvm.impl.ExecEnvImpl.loadModule(ExecEnvImpl.java:1242)
有人可以帮助我吗?
答案 0 :(得分:0)
您是否在ExecEnv
个实例中注册了元模型?在调用loadModule
之前,你应该有一段像这样的代码:
Metamodel inMetamodel = EmftvmFactory.eINSTANCE.createMetamodel();
inMetamodel.setResource(rs.getResource(URI.createURI(inputMetamodelNsURI), true));
env.registerMetaModel(IN_METAMODEL_NAME, inMetamodel);
Metamodel outMetamodel = EmftvmFactory.eINSTANCE.createMetamodel();
outMetamodel.setResource(rs.getResource(URI.createURI(outputMetamodelNsURI), true));
env.registerMetaModel(OUT_METAMODEL_NAME, outMetamodel);
在此示例中,OUT_METAMODEL_NAME
和IN_METAMODEL_NAME
是您在ATL转换中为元模型提供的名称。
This example我在GitHub上发现也可能有所帮助(归功于@guana)