java.io.IOException: The path is unmapped

1.8k views Asked by At

I'm trying to execute a QVTo transformation file in a Servlet page that runs on Apache server, but I'm getting "path unmapped" error.

This is part of my code:

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);

Both of these statements returns 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. 

and this is the error I'm getting:

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)

The files are in another project in the same workspace. I don't know where is the problem!

1

There are 1 answers

0
Alice On BEST ANSWER

I've solved this by executing the script in a "plugin project" not a "java project" + adding the required dependencies.