|
Re: Registering and loading a profile programatically (standalone) [message #1575046 is a reply to message #1573732] |
Tue, 20 January 2015 15:48   |
|
Hi, Ernesto,
This is happening because you put only the URI of the profile
*resource* into UML2's profile location map. At line 50 of your
ProfileTest.java, you need to map the profile namespace URI to the URI
of the root Profile *object* in the profile resource.
The consequence of putting the resource URI in this map is that the
UMLUtil::getProfile(...) method passes a URI having no fragment to the
ResourceSet::getEObject(...) API, which results on an NPE on the null
fragment.
HTH,
Christian
On 2015-01-19 22:46:15 +0000, Ernesto Posse said:
> Hi. I'm trying to load a model with a profile in a standalone application.
>
> I've followed the tutorial at
> http://wiki.eclipse.org/MDT/UML2/Introduction_to_UML2_Profiles#Loading_Models
>
>
> but that still doesn't clarify how to register a third-party profile.
>
> Some related threads suggest looking at UMLResourcesUtil to see how
> standard profiles are registered. Following the pattern there, I manage
> to register the profile (see attached file), and at first it seems to
> work, but as soon as I try to apply it, I get the following exception:
>
>
> applying profile:
> org.eclipse.uml2.uml.internal.impl.ProfileImpl@3e5c7b6b (name:
> UMLRealTime, visibility: <unset>) (URI:
> http://www.eclipse.org/papyrus/umlrt)
> java.lang.NullPointerException
> at
> org.eclipse.emf.ecore.resource.impl.ResourceImpl.getEObject(ResourceImpl.java:737)
>
> at
> org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getEObject(ResourceSetImpl.java:223)
>
> at org.eclipse.uml2.uml.util.UMLUtil.getProfile(UMLUtil.java:11298)
> at org.eclipse.uml2.uml.util.UMLUtil.getNamedElement(UMLUtil.java:11494)
> at org.eclipse.uml2.uml.util.UMLUtil.getNamedElement(UMLUtil.java:11444)
> at org.eclipse.uml2.uml.util.UMLUtil.getStereotype(UMLUtil.java:11506)
> at org.eclipse.uml2.uml.util.UMLUtil.getStereotype(UMLUtil.java:11533)
> at
> org.eclipse.uml2.uml.internal.operations.ElementOperations.getStereotypeApplications(ElementOperations.java:213)
>
> at
> org.eclipse.uml2.uml.internal.impl.ElementImpl.getStereotypeApplications(ElementImpl.java:186)
>
> at
> org.eclipse.uml2.uml.internal.operations.PackageOperations.applyProfile(PackageOperations.java:672)
>
> at
> org.eclipse.uml2.uml.internal.impl.PackageImpl.applyProfile(PackageImpl.java:1083)
>
> at
> eposse.experiments.profiletest.ProfileTest.applyProfiles(ProfileTest.java:75)
>
> at eposse.experiments.profiletest.ProfileTest.main(ProfileTest.java:34)
>
>
> If I comment out the line applying the profiles, I still get the same
> exception when invoking "getAppliedStereotypes".
>
> What's the problem what am I doing wrong?
>
> Thanks.
>
>
>
> <image><image>
|
|
|
|
Powered by
FUDForum. Page generated in 0.01826 seconds