Home » Modeling » UML2 » Loading UML-Model with papyrus-profile applied
Loading UML-Model with papyrus-profile applied [message #1058465] |
Tue, 14 May 2013 09:18 |
Ba sti Messages: 18 Registered: February 2013 |
Junior Member |
|
|
Hello,
i´m trying to load a uml-model with several profiles applied on, in a standalone-application in keplerM5. Everything works fine as long as it tries to access the Package with the uri "'http://Papyrus/schemas/Documentation/_vaU6gAEYEeCIz8iAxBJnfA/0'"
Here is the error message:
org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package with uri 'http://Papyrus/schemas/Documentation/_vaU6gAEYEeCIz8iAxBJnfA/0' not found. (file:/D:/.../MyModel.uml, 137, 105)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:77)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:185)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:259)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
at TestLoader.main(TestLoader.java:98)
Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://Papyrus/schemas/Documentation/_vaU6gAEYEeCIz8iAxBJnfA/0' not found. (file:/D:/.../MyModel.uml, 137, 105)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2599)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2429)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1306)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1475)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:81)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
... 4 more
and thats my code:
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("uml", new XMIResourceFactoryImpl());
resourceSet.getPackageRegistry().put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
resourceSet.getPackageRegistry().put(MyProfilePackage.eNS_URI, MyProfilePackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(resourceSet.getResourceFactoryRegistry().DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
Map uriMap = resourceSet.getURIConverter().getURIMap();
URI uri = URI.createFileURI("D:/.../MyModel.uml");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri.appendSegment("profiles").appendSegment(""));
EPackage.Registry.INSTANCE.put("D:/.../MyModel.uml",UMLPackage.eINSTANCE);
Resource resource = resourceSet.createResource(uri);
try {
resource.load(null); // Here it crashs..
System.out.println("Model: load complete");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
First i thought the problem is the older Metamodel of my model, but it also crashes in indigo wich has the right metamodel and it only crashes if the model contains references to this documentation..
Is it necessary to register 'http://Papyrus/schemas/Documentation/' or is there a special papyrusplugin that has to be installed?
Regards,
Basti
|
|
|
Re: Loading UML-Model with papyrus-profile applied [message #1059284 is a reply to message #1058465] |
Thu, 16 May 2013 12:32 |
|
Hi,
If your code is in an Eclipse plug-in running in an Eclipse instance,
then you don't need to do any of the registrations that you copied in
your post. Otherwise, the UMLResourcesUtil API can greatly simplify
your life.
The EMF run-time needs to be told where to find the EPackage for the
http://Papyrus/schemas/Documentation/_vaU6gAEYEeCIz8iAxBJnfA/0
namespace. This looks like a dynamic profile definition, so probably
there is an xsi:schemalocation mapping for this namespace in your model
file. It could be a platform:/plugin/... URI, in which case (if your
code is not running in Eclipse) you will need to register a URI mapping
to tell EMF where to find the profile resource in its JAR file.
HTH,
Christian
On 2013-05-14 09:18:48 +0000, Ba sti said:
> Hello,
>
> i´m trying to load a uml-model with several profiles applied on, in a
> standalone-application in keplerM5. Everything works fine as long as it
> tries to access the Package with the uri
> "'http://Papyrus/schemas/Documentation/_vaU6gAEYEeCIz8iAxBJnfA/0'"
> Here is the error message:
> org.eclipse.emf.ecore.resource.Resource$IOWrappedException: Package
> with uri
> 'http://Papyrus/schemas/Documentation/_vaU6gAEYEeCIz8iAxBJnfA/0' not
> found. (file:/D:/.../MyModel.uml, 137, 105)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:77)
>
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:185)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLResourceImpl.java:259)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1518)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(ResourceImpl.java:1297)
>
> at TestLoader.main(TestLoader.java:98)
> Caused by: org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package
> with uri
> 'http://Papyrus/schemas/Documentation/_vaU6gAEYEeCIz8iAxBJnfA/0' not
> found. (file:/D:/.../MyModel.uml, 137, 105)
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(XMLHandler.java:2599)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefix(XMLHandler.java:2429)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType(XMLHandler.java:1306)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XMLHandler.java:1475)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XMLHandler.java:1026)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMIHandler.processElement(XMIHandler.java:81)
>
> at
> org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:1008)
>
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHandler.java:719)
> at org.eclipse.emf.ecore.xmi.impl.XMIHandler.startElement(XMIHandler.java:163)
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown
> Source)
> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
> at
> com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown
> Source)
> at
> com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown
> Source)
> at javax.xml.parsers.SAXParser.parse(Unknown Source)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.java:175)
> ... 4 more
> and thats my code:
> ResourceSet resourceSet = new ResourceSetImpl();
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("uml",
> new XMIResourceFactoryImpl());
> resourceSet.getPackageRegistry().put(SysmlPackage.eNS_URI,
> SysmlPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(BlocksPackage.eNS_URI,
> BlocksPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI,
> EcorePackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(MyProfilePackage.eNS_URI,
> MyProfilePackage.eINSTANCE);
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(resourceSet.getResourceFactoryRegistry().DEFAULT_EXTENSION,
> new XMIResourceFactoryImpl());
> Map uriMap = resourceSet.getURIConverter().getURIMap();
> URI uri = URI.createFileURI("D:/.../MyModel.uml");
> uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
> uri.appendSegment("libraries").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
> uri.appendSegment("metamodels").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP),
> uri.appendSegment("profiles").appendSegment(""));
>
> EPackage.Registry.INSTANCE.put("D:/.../MyModel.uml",UMLPackage.eINSTANCE);
> Resource resource = resourceSet.createResource(uri);
> try {
> resource.load(null); // Here it crashs..
> System.out.println("Model: load complete");
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> First i thought the problem is the older Metamodel of my model, but it
> also crashes in indigo wich has the right metamodel and it only crashes
> if the model contains references to this documentation..
> Is it necessary to register 'http://Papyrus/schemas/Documentation/' or
> is there a special papyrusplugin that has to be installed?
>
> Regards,
> Basti
|
|
|
Re: Loading UML-Model with papyrus-profile applied [message #1060093 is a reply to message #1059284] |
Thu, 23 May 2013 06:23 |
Ba sti Messages: 18 Registered: February 2013 |
Junior Member |
|
|
Hi,
thanks for your help.
You were right, there was a pathmap - mapping missing, now its loading without any errors.
But now i have an other problem. In my Model there are more than 5000 Elements with at least 1 stereotypes applied on, but after loading the model I can only access nearly the halve of these stereotypes.
I changed my code to this:
ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION, UMLResource.Factory.INSTANCE);
resourceSet.getPackageRegistry().put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE);
resourceSet.getPackageRegistry().put(MyProfilePackage.eNS_URI, MyProfilePackage.eINSTANCE);
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(resourceSet.getResourceFactoryRegistry().DEFAULT_EXTENSION, new XMIResourceFactoryImpl());
Map<URI,URI> uriMap = resourceSet.getURIConverter().getURIMap();
UMLResourcesUtil.init(resourceSet);
final URI uri2 = URI.createURI("jar:file:D:/.../plugins/org.eclipse.uml2.uml.resources_4.1.0.v20130506-1015.jar!/");
URI uri = URI.createFileURI("D:/.../MyModel.uml");
uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP), uri2.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP), uri2.appendSegment("metamodels").appendSegment(""));
uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP), uri2.appendSegment("profiles").appendSegment(""));
uriMap.put(URI.createURI("pathmap://Papyrus.profile.uml"),URI.createURI("file:/D:/.../Papyrus.profile.uml/"));
EPackage.Registry.INSTANCE.put("D:/.../MyModel.uml",UMLPackage.eINSTANCE);
Resource resource = resourceSet.createResource(uri);
try {
resource.load(null);
System.out.println("Model: load complete");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Model m = (Model) EcoreUtil.getObjectByType(resource.getContents(), UMLPackage.Literals.MODEL);
if(m==null){
System.err.println("Model: load failed!");
System.exit(1);
}
EList<Element> list = m.allOwnedElements();
//count number of Elements with at least one stereotype
int stereo = 0;
for(int i=0;i<list.size();i++){
if(list.get(i).getAppliedStereotypes().size() > 0){
stereo++;
}
}
the stereotypes missing, are the primitive SysML stereotypes like Block or FlowPort etc.
How can i get these other halve of my stereotypes?
Regards,
Basti
[Updated on: Thu, 23 May 2013 09:07] Report message to a moderator
|
|
|
Re: Loading UML-Model with papyrus-profile applied [message #1060187 is a reply to message #1060093] |
Thu, 23 May 2013 12:32 |
|
Hi, Basti,
Which stereotypes are missing? Are they defined by a different
profile? (I would expect so) Note that if that profile is statically
defined, then you will need also to initialize its generated package in
the registry and also add the profile to UML2's profile registry to
ensure that the stereotype applications can be traced back to the UML
Stereotypes that model them.
HTH,
Christian
On 2013-05-23 06:23:33 +0000, Ba sti said:
> Hi,
>
> thanks for your help.
> You were right, there was a pathmap - mapping missing, now its loading
> without any errors.
>
> But now i have an other problem. In my Model there are more than 5000
> Elements with at least 1 stereotypes applied on, but after loading the
> model I can only access nearly the halve of these stereotypes.
> I changed my code to this:
> ResourceSet resourceSet = new ResourceSetImpl();
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
> resourceSet.getPackageRegistry().put(SysmlPackage.eNS_URI,
> SysmlPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(BlocksPackage.eNS_URI,
> BlocksPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI,
> UMLPackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI,
> EcorePackage.eINSTANCE);
> resourceSet.getPackageRegistry().put(MyProfilePackage.eNS_URI,
> MyProfilePackage.eINSTANCE);
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(resourceSet.getResourceFactoryRegistry().DEFAULT_EXTENSION,
> new XMIResourceFactoryImpl());
> Map<URI,URI> uriMap = resourceSet.getURIConverter().getURIMap();
>
>
>
>
> UMLResourcesUtil.init(resourceSet);
>
> final URI uri2 =
> URI.createURI("jar:file:D:/.../plugins/org.eclipse.uml2.uml.resources_4.1.0.v20130506-1015.jar!/");
>
>
> URI uri = URI.createFileURI("D:/.../MyModel.uml");
> uriMap.put(URI.createURI(UMLResource.LIBRARIES_PATHMAP),
> uri2.appendSegment("libraries").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.METAMODELS_PATHMAP),
> uri2.appendSegment("metamodels").appendSegment(""));
> uriMap.put(URI.createURI(UMLResource.PROFILES_PATHMAP),
> uri2.appendSegment("profiles").appendSegment(""));
>
> uriMap.put(URI.createURI("pathmap://Papyrus.profile.uml"),URI.createURI("file:/D:/.../Papyrus.profile.uml/"));
>
>
> EPackage.Registry.INSTANCE.put("D:/.../MyModel.uml",UMLPackage.eINSTANCE);
> Resource resource = resourceSet.createResource(uri);
> try {
> resource.load(null);
> System.out.println("Model: load complete");
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> Model m = (Model) EcoreUtil.getObjectByType(resource.getContents(),
> UMLPackage.Literals.MODEL);
> if(m==null){
> System.err.println("Model: load failed!");
> System.exit(1);
> }
>
> EList<Element> list = m.allOwnedElements();
> //count number of Elements with at least one stereotype
> int stereo = 0;
> for(int i=0;i<list.size();i++){
> if(list.get(i).getAppliedStereotypes().size() > 0){
> stereo++;
> }
> }
> How can i get the other halve of my stereotypes?
>
> Regards,
> Basti
|
|
| |
Goto Forum:
Current Time: Fri Apr 26 11:50:05 GMT 2024
Powered by FUDForum. Page generated in 0.03441 seconds
|