Home » Modeling » M2T (model-to-text transformation) » Cannot Access Stereotypes
|
Re: Cannot Access Stereotypes [message #1730347 is a reply to message #1730246] |
Mon, 25 April 2016 08:31 |
Eclipse User |
|
|
|
Hi Daniel,
Did you include 'http://www.eclipse.org/uml2/5.0.0/UML' in the
definition of the module?
Best,
Víctor
El 22/04/2016 a las 16:27, Daniel Clarke escribió:
> 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 16:28 |
Ed Willink Messages: 7676 Registered: July 2009 |
Senior Member |
|
|
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 08:26 |
Daniel Clarke Messages: 24 Registered: March 2016 |
Junior Member |
|
|
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 08:38 |
Ed Willink Messages: 7676 Registered: July 2009 |
Senior Member |
|
|
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.
|
|
| | |
Goto Forum:
Current Time: Thu Oct 10 20:37:03 GMT 2024
Powered by FUDForum. Page generated in 0.04609 seconds
|