Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [ACCELEO] Null return in using pointer
[ACCELEO] Null return in using pointer [message #953876] Mon, 22 October 2012 15:58 Go to next message
Nicolas BRODNAN is currently offline Nicolas BRODNANFriend
Messages: 4
Registered: October 2012
Junior Member
Hy,

I am using the 3.3.1 Acceleo version on Eclipse Juno, and i want to get the guard of a transition. To do that i have an operation getGuard() on my transition, but she is redefined by a stereotype. When i access to my opération getGuard() by my stereotype, i have always a null return!
static public Algorithm getTransitionGuard(Transition transition)
{
Algorithm result = null;

org.eclipse.papyrus.RobotML.Transition robotml_transition = ElementUtil.getStereotypeApplication(transition, org.eclipse.papyrus.RobotML.Transition.class);

if(robotml_transition != null)
{
result = robotml_transition.getGuard();
}
return result;
}


Can you help me?
Re: [ACCELEO] Null return in using pointer [message #956359 is a reply to message #953876] Wed, 24 October 2012 12:50 Go to previous messageGo to next message
saadia dhouib is currently offline saadia dhouibFriend
Messages: 36
Registered: April 2010
Member
I am going to add more information about the problem:
We have a UML model with a static profile applied on it.
We want to make model to text transformation using acceleo.
We have a stereotype <<transition>> that extends transition from UML2.
<<transition>> has a property named "guard" which is typed by another stereotype.

When we try to retreive the value of the guard, we have a nullpointer exception. We tried to do the same with a simple java program that take as input the model with the same static profile applied on it, and we succeeded to retrieve the value of the "guard" attribute of the "transition" stereotype.

So we are sure that the problem comes from Acceleo engine.
Re: [ACCELEO] Null return in using pointer [message #956510 is a reply to message #956359] Wed, 24 October 2012 15:10 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Or from your initialization of the Acceleo engine.

Have you followed the instruction in the generated TRansformation file
which has some clues for UML?

Regards

Ed Willink

On 24/10/2012 14:50, saadia dhouib wrote:
> I am going to add more information about the problem:
> We have a UML model with a static profile applied on it.
> We want to make model to text transformation using acceleo.
> We have a stereotype <<transition>> that extends transition from UML2.
> <<transition>> has a property named "guard" which is typed by another
> stereotype.
>
> When we try to retreive the value of the guard, we have a nullpointer
> exception. We tried to do the same with a simple java program that
> take as input the model with the same static profile applied on it,
> and we succeeded to retrieve the value of the "guard" attribute of the
> "transition" stereotype.
>
> So we are sure that the problem comes from Acceleo engine.
Re: [ACCELEO] Null return in using pointer [message #957456 is a reply to message #956510] Thu, 25 October 2012 08:34 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi Nicolas, Saadia,

As Ed pointed out, you will have to make sure you load your UML models correctly for Acceleo. In short, you cannot just load the 'model.uml' file and expect it to work. The generated java launcher has a number of comments on how to properly initialize and load UML models, please look at them and make sure to follow the instructions.

Most of these instructions are simply copied from the UML wiki.

You might also want to check "how" you are launching the Acceleo transformation. If you are using a run configuration, check whether you are launching the generation as "Acceleo Application" (standalone, needs all UML initialization to be done manually in the launcher) or "Acceleo plug-in Application" (runs as an Eclipse plugin, should be able to load UML models without you adding more initialization code).

Laurent Goubet
Obeo
Re: [ACCELEO] Null return in using pointer [message #958983 is a reply to message #953876] Fri, 26 October 2012 11:10 Go to previous messageGo to next message
Nicolas BRODNAN is currently offline Nicolas BRODNANFriend
Messages: 4
Registered: October 2012
Junior Member
Hi,

Thanks for your help.

I run my project as "Eclipse application". And i initialize my acceleo engine as follows:

In my template file (.mtl)
[module generateAthena('http://www.eclipse.org/uml2/3.0.0/UML', 'http//Papyrus/RobotML/1)'/]


In my module java code
public void registerPackages(ResourceSet resourceSet) {
        super.registerPackages(resourceSet);
        if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) {
        	resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
        }
        if (!isInWorkspace(org.eclipse.papyrus.RobotML.RobotMLPackage.class)) {
            resourceSet.getPackageRegistry().put(RobotMLPackage.eNS_URI, RobotMLPackage.eINSTANCE);
        }
    }


I have test to add UMLResource, but it's not the solution.
Re: [ACCELEO] Null return in using pointer [message #963018 is a reply to message #958983] Mon, 29 October 2012 14:04 Go to previous messageGo to next message
saadia dhouib is currently offline saadia dhouibFriend
Messages: 36
Registered: April 2010
Member
We had the problem only if we try to retrieve the value of stereotype's property that references an another stereotype.
For example:
For the stereotype
Port:
buffer : Integer

We can retrieve the value of the property buffer.

For the stereotype
Transition:
guard: Algorithm
We can not retrieve the value of the guard which references another stereotype "Algorithm"




Re: [ACCELEO] Null return in using pointer [message #975981 is a reply to message #963018] Thu, 08 November 2012 08:18 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi,

So you can retrieve the value of some stereotypes... but not others. Do you have the proper initialization for the "other" stereotypes? "Algorithm" in saadia's above example is what cannot be resolved. Where is this stereotype located?

When you load the initial model from the generated Acceleo launcher, you can try and see if there are any unresolvable proxies through a method such as this called just before the acceleo engine in doGenerate (costly, but can be effective to debug) :

private void checkForUnresolvedProxies(Resource res) {
  TreeIterator<EObject> allContent = EcoreUtil.getAllContent(res, true);
  while (allContent.hasNext()) {
    EObject next = allContent.next();
    if (next.eIsProxy()) {
      throw new RuntimeException("Unresolved proxy : " + ((InternalEObject)next).eProxyURI());
    }
    for (EObject crossReference : next.eCrossReferences()) {
      if (crossReference.eIsProxy()) {
        throw new RuntimeException("Unresolved proxy : " + ((InternalEObject)crossReference).eProxyURI());
      }
    }
  }
}


This is a little "brute force"... but it should allow you to determine if there are any unresolveable proxies referenced by your model, even for UML. If this code cannot resolve a proxy, Acceleo won't either. This will throw exceptions for each proxy encountered, giving you the URI that could not be resolved. This URI is what your are missing initialization code for.

Laurent Goubet
Obeo
Re: [ACCELEO] Null return in using pointer [message #981493 is a reply to message #975981] Mon, 12 November 2012 13:04 Go to previous messageGo to next message
Nicolas BRODNAN is currently offline Nicolas BRODNANFriend
Messages: 4
Registered: October 2012
Junior Member
I have test your code, but i don't have any exception.
Re: [ACCELEO] Null return in using pointer [message #982579 is a reply to message #981493] Tue, 13 November 2012 08:44 Go to previous messageGo to next message
saadia dhouib is currently offline saadia dhouibFriend
Messages: 36
Registered: April 2010
Member
The stereotype <<Algorithm>> is located in the same profile than <<Transition>>
Re: [ACCELEO] Null return in using pointer [message #985785 is a reply to message #982579] Fri, 16 November 2012 07:58 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Saadia, Nicolas,

Can you provide us with a minimal sample with which we could reproduce this locally? Preferrably through a bugzilla against Acceleo.

Laurent Goubet
Obeo
Re: [ACCELEO] Null return in using pointer [message #985945 is a reply to message #985785] Fri, 16 November 2012 19:26 Go to previous messageGo to next message
Nicolas BRODNAN is currently offline Nicolas BRODNANFriend
Messages: 4
Registered: October 2012
Junior Member
Hi,

By the test project, I realized that everything worked. I redid my state machine of my project, and that to solve the problem. The problem comes from a change in our profile.


Thank you for your help.

Re: [ACCELEO] Null return in using pointer [message #986148 is a reply to message #985945] Mon, 19 November 2012 08:29 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi,

Thanks for the confirmation Smile.

Laurent Goubet
Obeo
Previous Topic:Acceleo releases
Next Topic:[Acceleo] EMTL files not contained in build
Goto Forum:
  


Current Time: Fri Mar 29 15:49:26 GMT 2024

Powered by FUDForum. Page generated in 0.03466 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top