Home » Modeling » M2T (model-to-text transformation) » Cannot Access Stereotypes
Cannot Access Stereotypes [message #1730246] |
Fri, 22 April 2016 10:27  |
Eclipse User |
|
|
|
Hi,
I am new to Acceleo and am trying to access stereotypes, but it does not seem to work.
I have used Papyrus to generate a UML Profile and then created a model (which applies the profile) whereby I have used some of the stereotypes.
I am then trying to use Acceleo to simply print a list of stereotypes applied to an element of the model using the following code:
[for (aST : Stereotype | aClass.getAppliedStereotypes())]
stereotype = [aST.name/]
[/for]
However, this does not return any stereotypes when I am expecting it to.
Have I missed something?
I was following this guide:
http://devsolstice.blogspot.co.uk/2012/04/acceleo-uml-profiles-papyrus-good.html
Regards,
Dan
|
|
| | | | | |
Re: Cannot Access Stereotypes [message #1730423 is a reply to message #1730421] |
Mon, 25 April 2016 12:28   |
Eclipse User |
|
|
|
Hi
UMLResourcesUtil.init(resourceSet) should replace all the code you have
quoted.
When the UML2 project added UML 2.4.1 and 2.5 support, the required
initializations were too complex even for experts. Hence the new single
routine that just does it.
If you can't use it add org.eclipse.uml2.uml.resources to your required
bundles.
Regards
Ed Willink
On 25/04/2016 16:50, Daniel Clarke wrote:
> Ed,
>
> Sorry I don't follow what you mean.
>
> I currently have:
>
>
> resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(UMLResource.FILE_EXTENSION,
> UMLResource.Factory.INSTANCE);
>
> in registerResourceFactories() and:
>
> Map<URI, URI> uriMap =
> resourceSet.getURIConverter().getURIMap();
> // UML2 profiles
> URI uri =
> URI.createURI("platform:/plugin/org.eclipse.uml2.uml.resources");
> 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(""));
> in registerPackages().
>
> Are you suggesting I add the "UMLResourcesUtil.init(resourceSet); "
> line also into registerPackages? I've tried doing this but can an
> error as follows: "org.eclipse.uml2.uml.resources cannot be resolved".
>
> Again, guidance appreciated :)
|
|
|
Re: Cannot Access Stereotypes [message #1730627 is a reply to message #1730423] |
Wed, 27 April 2016 04:26   |
Eclipse User |
|
|
|
Ed,
Thanks, I can now get something to generate and access stereotypes (only when using the Acceleo Plug-in Application runner - I cannot get it to run using the default Java Application runner).
However, I'm seeing some very strange behaviour - when I run the first time (after starting Eclipse) it generates as expected, but every subsequent run generates a number of errors (and warnings):
java.lang.NullPointerException
at org.eclipse.osgi.internal.loader.BundleLoader.findRequiredSource(BundleLoader.java:1114)
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:392)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Unsafe.defineClass(Native Method)
at sun.reflect.ClassDefiner.defineClass(Unknown Source)
at sun.reflect.MethodAccessorGenerator$1.run(Unknown Source)
at sun.reflect.MethodAccessorGenerator$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
and this warning....
org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid result for expression self.invoke('ecoa.transformation.common.UML2Services', 'hasStereotype(org.eclipse.uml2.uml.Element, java.lang.String)', Sequence {arg0, arg1}) at line 0 in Module uml2services for query hasStereotype(Element,String). Last recorded value of self was org.eclipse.uml2.uml.internal.impl.DataTypeImpl@56035798 (name: value_type, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false). Problem found while generating the file 'D:\test.xml'.
If I close and restart Eclipse, the generation again works the first time; every subsequent time fails with a set of the above NPE and warning pairs. It is a real pain having to restart Eclipse every time I want to re-run... Any thoughts?
Thanks again.
|
|
|
Re: Cannot Access Stereotypes [message #1730630 is a reply to message #1730627] |
Wed, 27 April 2016 04:38   |
Eclipse User |
|
|
|
Hi
The debugger is always your friend.
Regards
Ed Willink
On 27/04/2016 09:26, Daniel Clarke wrote:
> Ed,
>
> Thanks, I can now get something to generate and access stereotypes
> (only when using the Acceleo Plug-in Application runner - I cannot get
> it to run using the default Java Application runner).
>
> However, I'm seeing some very strange behaviour - when I run the first
> time (after starting Eclipse) it generates as expected, but every
> subsequent run generates a number of errors (and warnings):
>
>
> java.lang.NullPointerException
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findRequiredSource(BundleLoader.java:1114)
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:392)
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:352)
> at
> org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:344)
> at
> org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
> at java.lang.ClassLoader.loadClass(Unknown Source)
> at sun.misc.Unsafe.defineClass(Native Method)
> at sun.reflect.ClassDefiner.defineClass(Unknown Source)
> at sun.reflect.MethodAccessorGenerator$1.run(Unknown Source)
> at sun.reflect.MethodAccessorGenerator$1.run(Unknown Source)
> at java.security.AccessController.doPrivileged(Native Method)
>
> and this warning....
>
> org.eclipse.acceleo.engine.AcceleoEvaluationException: Invalid result
> for expression self.invoke('ecoa.transformation.common.UML2Services',
> 'hasStereotype(org.eclipse.uml2.uml.Element, java.lang.String)',
> Sequence {arg0, arg1}) at line 0 in Module uml2services for query
> hasStereotype(Element,String). Last recorded value of self was
> org.eclipse.uml2.uml.internal.impl.DataTypeImpl@56035798 (name:
> value_type, visibility: <unset>) (isLeaf: false, isAbstract: false,
> isFinalSpecialization: false). Problem found while generating the file
> 'D:\test.xml'.
>
>
> If I close and restart Eclipse, the generation again works the first
> time; every subsequent time fails with a set of the above NPE and
> warning pairs. It is a real pain having to restart Eclipse every time
> I want to re-run... Any thoughts?
>
> Thanks again.
|
|
| |
Re: Cannot Access Stereotypes [message #1730779 is a reply to message #1730748] |
Thu, 28 April 2016 08:33  |
Eclipse User |
|
|
|
Hi
You can always debug by running in a nested Eclipse, or by connecting a
remote Eclipse.
Silently ignoring things is very unhelpful. Probably worth raising a
Buzilla on Acceleo for the silence and Papyrus for the inconsistency.
I have found that it is difficult to make Acceleo URI resolution
useable; one reason I no longer use Acceleo.
The plugin launcher has been broken for at least a few years and its
confusing presence should end soon.
Regards
Ed Willink
On 28/04/2016 09:57, Daniel Clarke wrote:
> Ed,
>
> After much debugging (which only works using the the Java Runner), I
> figured out that it was silently failing to find my UML Profile. The
> profile was generated using Papyrus, and it seems that the location of
> the profile was not being set properly. The location was set to
> "/My_Profile/my.profile.uml". It looks like if you apply a profile
> when you create a new Papyrus model (using the new Papyrus model
> wizard) it sets the location in this fashion, but if you apply a
> profile after you have created a model (i.e. not using the wizard) it
> sets it in the form "platform:/resource/My_Profile/my.profile.uml".
>
> I'm not sure if this is a bug in Papyrus, but updating to the
> "platform:/" form has fixed my issue and now it runs OK using the Java
> Runner.
>
> I don't know why the Acceleo Plug-in Runner is behaving strangely
> still (i.e. generates only the first time after starting Eclipse -
> and I can't debug it to investigate) but I'm happy enough to use the
> Java Runner now which is working alright.
>
> Thanks for your support!
|
|
|
Goto Forum:
Current Time: Thu May 15 18:21:30 EDT 2025
Powered by FUDForum. Page generated in 0.05962 seconds
|