Hi,
i try to open a bpel file with following code:
BPELPackage.eINSTANCE.eClass();
Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
Map<String, Object> m = reg.getExtensionToFactoryMap();
m.put("bpel", new BPELResourceFactoryImpl());
ResourceSet resSet = new ResourceSetImpl();
URI uri = URI.createURI("test/SynchronousSample.bpel");
Resource resource = resSet.getResource(uri, true);
Process process = (Process)resource.getContents().get(0);
and i got some error messages:
Exception in thread "main" java.lang.IllegalStateException: INamespaceMap
cannot be attached to an eObject
at
org.eclipse.bpel.model.util.BPELUtils.getNamespaceMap(BPELUt ils.java:260)
at
org.eclipse.bpel.model.resource.BPELReader.saveNamespacePref ix(BPELReader.java:512)
at
org.eclipse.bpel.model.resource.BPELReader.xml2Process(BPELR eader.java:932)
at
org.eclipse.bpel.model.resource.BPELReader.xml2Resource(BPEL Reader.java:912)
at org.eclipse.bpel.model.resource.BPELReader.pass1(BPELReader. java:389)
at org.eclipse.bpel.model.resource.BPELReader.read(BPELReader.j ava:321)
at
org.eclipse.bpel.model.resource.BPELResourceImpl.doLoad(BPEL ResourceImpl.java:132)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1445)
at
org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1241)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
at
org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
at main(Loadtest.java:38)
i do not know how to solve it. Can anyone give me some advices?
Robert Brodt Messages: 343 Registered: August 2010 Location: Colorado Springs, CO
Senior Member
Hi all,
I suggest you have a look at the org.eclipse.bpel.ui.util.BPELReader class - this is used by the editor to load the BPEL model and does a bunch of (necessary!) initialization, including the namespace map.