Quentin,
This is like an EMF FAQ thing:
2.17 I get a
PackageNotFoundException: e.g., "Package with uri
'http://com.example.company.ecore' not found." What do I need to do?
I take it you are running standalone? Have you found the package
whose eNS_URI value matches the URI in the exception?
The thing worries me. Generally you'll want to use an absolute URI
URI fileURI = URI.createFileURI("EPF4/export.xmi");
I.e.,
URI fileURI = URI.createFileURI(new
File("EPF4/export.xmi").getAbsolutePath());
This is especially important if the file can reference other files...
Probably a little bit of background reading will help:
The
Eclipse Modeling Framework Overview
Quentin DEME wrote:
I finally succeeded in having a result from my program.
Now I unfortunately have another problem. I get the following error:
Exception in thread "main"
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl$1DiagnosticWrappedException:
org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
'http:///org/eclipse/epf/uma/resourcemanager.ecore' not found.
(file:///C:/myWorkspace/testprj/EPF4/export.xmi, 3, 118)
The file I'm trying to read (export.xmi) is an EPF Composer output
file. It's heading is:
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI epf:version="1.2.0" xmi:version="2.0"
xmlns:epf="http://www.eclipse.org/epf"
xmlns:org.eclipse.epf.uma="http://www.eclipse.org/epf/uma/1.0.4/uma.ecore"
xmlns:org.eclipse.epf.uma.resourcemanager="http:///org/eclipse/epf/uma/resourcemanager.ecore"
xmlns:xmi="http://www.omg.org/XMI">
<org.eclipse.epf.uma.resourcemanager:ResourceManager
guid="_mtb_FPL5Edm6Nvont3uinw" xmi:id="_mtb_FPL5Edm6Nvont3uinw">
The current code is:
public class TestEPFXMIParser {
public TestEPFXMIParser() {
// create a ResourceSet.
ResourceSet resourceSet = new ResourceSetImpl();
//org.eclipse.epf.library.LibraryService.getInstance().openMethodLibrary(String,uri);
// initialize ResourceSet
final ExtendedMetaData extendedMetaData = new
BasicExtendedMetaData(resourceSet.getPackageRegistry());
resourceSet.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA,
extendedMetaData);
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(NotationPackage.eNS_URI,
NotationPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(ModelPackage.eNS_URI,
ModelPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(UmaPackage.eNS_URI,
UmaPackage.eINSTANCE);
System.out.println("URI = " + ModelPackage.eNS_URI);
resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI,
EcorePackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xmi",
new XMIResourceFactoryImpl());
URI fileURI = URI.createFileURI("EPF4/export.xmi");
Resource resource = resourceSet.getResource(fileURI, true);
}
}
I don't really understand these "Package" notions, can you explain me
the right way to use them and how to solve this problem ?
By the way, I found a post that is quite exactly similar to mine, and
to which nobody had answered. If it can help you:
http://www.mail-archive.com/epf-dev@xxxxxxxxxxx/msg01586.html
Thanks a lot
Quentin
|