a registered resource factory is needed" outside the generated editor [message #1854061] |
Fri, 29 July 2022 20:53  |
Eclipse User |
|
|
|
Here is my snipped of code for my loader as it would not read any file outside of files inside the folder
public class EMFModelLoad {
public RootPIM load(String file) {
// Initialise the model
PIMPackage.eINSTANCE.eClass();
// Register the XMI resource factory for the .website extension
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("PIM", new XMIResourceFactoryImpl());
// Obtain a new resource set
ResourceSet resSet = new ResourceSetImpl();
resSet.setResourceFactoryRegistry(reg);
// resSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("PIM", new
// XMLResourceFactoryImpl());
Resource resource = resSet.getResource(URI.createURI(file), true);
RootPIM pimRoot = (RootPIM) resource.getContents().get(0);
// return pimRoot;
return pimRoot;
}
}
------------------------CONSOLE LOG --------------------
Exception in thread "main" java.lang.RuntimeException: Cannot create a resource for 'c:\test\TrainTicket.PIM'; a registered resource factory is needed
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResource(ResourceSetImpl.java:403)
at EMFModelLoad.load(EMFModelLoad.java:30)
at main.main(main.java:29)
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02535 seconds