2

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!

Alice
  • 117
  • 5
  • 16
  • Why is 'C:' missing from the error log? – Maas Aug 11 '14 at 09:56
  • Sorry it was by mistake, I've edited it. – Alice Aug 11 '14 at 10:05
  • is a client based application that you are trying to pull the file path? – Will Mcavoy Aug 11 '14 at 10:11
  • It is a dynamic webapplication, and I'm trying to get these files in a servlet doGet method as an input to my qvt script (InputStream). I think the workspaceRoot is Null, but I don't know how to fix that. – Alice Aug 11 '14 at 10:21
  • This returns null: IWorkspaceRoot workspaceRoot = EcorePlugin.getWorkspaceRoot(); – Alice Aug 11 '14 at 10:27
  • According to JavaDoc : Returns the workspace root, or null, if the runtime environment is stand-alone. Are you running in StandAlone mode? – Maas Aug 11 '14 at 10:31
  • This also returns null: String platformResourcePath = uri.toPlatformString(true); URI resolvedLocation = EcorePlugin.resolvePlatformResourcePath(platformResourcePath); after defining a uri with the file path specified in the question. – Alice Aug 11 '14 at 10:37
  • I'm running it as a web app on Apache server, what do you mean by standalone mode? – Alice Aug 11 '14 at 10:40
  • http://smatrt.googlecode.com/svn/trunk/tmp/org/eclipse/emf/ecore/resource/impl/PlatformResourceURIHandlerImpl.java .. this java file contains the class that returns the exception (createInputStream) – Alice Aug 11 '14 at 10:48

1 Answers1

1

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

Alice
  • 117
  • 5
  • 16