我试图在两个模型之间进行转换,除了在独立模式下使用eclipse之外,每件事似乎都是正常的,我在尝试从java编程执行transformation时出现了错误,
如何解决这个问题?它的鱼缸。谢谢你的帮助,也很抱歉我的英语不好。
错误:
ResourcesPlugin.getWorkspace().getRoot();线程“主”java.lang.IllegalStateException:工作区中的异常已关闭。在org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:399)
File f = new File(Path);
URI transformationURI = URI.createFileURI(f.getAbsolutePath());
resource = resourceSet.getResource(transformationURI, true);`org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: org.xml.sax.SAXParseException: org.xml.sax.SAXParseException线程中的异常在prolog中是不允许的。在org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:315) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274) at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
当我省略这一行时:
//resource = resourceSet.getResource(transformationURI, true);我还有另外一个例外:
org.eclipse.m2m.qvt.oml.TransformationExecutor.doLoad(TransformationExecutor.java:205) at org.eclipse.m2m.qvt.oml.TransformationExecutor.loadTransformation(TransformationExecutor.java:108) at org.eclipse.m2m.qvt.oml.TransformationExecutor.execute(TransformationExecutor.java:137)上的线程"main“java.lang.ExceptionInInitializerError中的异常 造成: org.eclipse.m2m.internal.qvt.oml.compiler.UnitResolverFactory$Registry$1.readFactories(UnitResolverFactory.java:66) at org.eclipse.m2m.internal.qvt.oml.compiler.UnitResolverFactory$Registry$1.(UnitResolverFactory.java:44) at org.eclipse.m2m.internal.qvt.oml.compiler.UnitResolverFactory$Registry.(UnitResolverFactory.java:43) .6
发布于 2014-02-21 17:48:13
正如this question中所介绍的,您必须运行一个Eclipse应用程序,以确保完成所有必要的Eclipse设置。
对于没有UI的“无头”应用程序,IApplication类可以非常简单:
public class Application implements IApplication
{
@Override
public Object start(final IApplicationContext context)
throws Exception
{
.. your code here ...
return IApplication.EXIT_OK;
}
@Override
public void stop()
{
// No action
}
private static void ensurePluginStarted(String id)
{
Bundle bundle = Platform.getBundle(id);
if (bundle != null)
{
if ((bundle.getState() & Bundle.ACTIVE) == 0)
{
try
{
bundle.start(Bundle.START_TRANSIENT);
}
catch (BundleException ex)
{
ex.printStackTrace();
}
}
}
}
}此应用程序可以使用Eclipse工作区,但不能使用UI。在某些情况下,可能需要调用ensurePluginStarted方法,以确保将要使用的所有插件都在运行。任何尝试使用UI的插件都会失败。
如果您想要一个UI,那么需要一个完整的Eclipse。
https://stackoverflow.com/questions/21933636
复制相似问题