2

我正在尝试在 Apache 服务器上运行的 Servlet 页面中执行 QVTo 转换文件,但出现“路径未映射”错误。

这是我的代码的一部分:

ResourceSet resourceSet = new ResourceSetImpl();
Registry reg = Registry.INSTANCE; 
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi", new XMIResourceFactoryImpl());
ProjectMap.getAdapter(resourceSet);
EPackage testA = (EPackage)(resourceSet.getResource(URI.createPlatformResourceURI("file:///C:/Users/me.me/EclipsJEEworkspace/some_project/models/somefile.ecore", true), true)).getContents().get(0);
reg.put(testA.getNsURI(), testA);
Resource  inResource = resourceSet.getResource(URI.createURI("file:///C:/Users/me.me/EclipsJEEworkspace/some_project/models/tenant1_PIM.xmi"),true);
EPackage testB = (EPackage)(resourceSet.getResource(URI.createPlatformResourceURI("file:///C:/Users/me.me/EclipsJEEworkspace/some_project/models/somefile.ecore", true), true)).getContents().get(0);
reg.put(testB.getNsURI(), testB);

这两个语句都返回 null:

IWorkspaceRoot workspaceRoot = EcorePlugin.getWorkspaceRoot();
String platformResourcePath = uri.toPlatformString(true); URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath); //after defining a uri with the file path specified in the question. 

这是我得到的错误:

org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException: java.io.IOException: The path '/file:///C:/Users/me.me/EclipsJEEworkspace/some_project/models/somefile.ecore' is unmapped
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.handleDemandLoadException(ResourceSetImpl.java:315)
    org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLoadHelper(ResourceSetImpl.java:274)
    org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:397)
    org.saas.mda.tenanthandler.tenantServlet.doGet(tenantServlet.java:321)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

这些文件位于同一工作区的另一个项目中。不知道问题出在哪里!

4

1 回答 1

1

我已经通过在“插件项目”而不是“java项目”中执行脚本+添加所需的依赖项来解决这个问题。

于 2014-08-13T10:25:15.813 回答