Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » IllegalArgumentException in navigateProperty
IllegalArgumentException in navigateProperty [message #1760082] Sat, 22 April 2017 03:11 Go to next message
Nicholas Johnson is currently offline Nicholas JohnsonFriend
Messages: 10
Registered: March 2017
Junior Member
Good Day,
I'm an EMF/Acceleo noob and I'm running into some problems getting my text to generate correctly from my templates.

I'm trying to use Acceleo to generate code for a message translator. I have metamodels for the 2 different message formats (mm1 and mm2) and a 3rd metamodel (mm3) that lets me specify the input and output messages for the translation.

mm1 and the generated model classes is defined in a separate plugin, while mm2 and mm3 are together in a different plugin but are 2 separate ecore files. I have a genmodel for mm1 and a single genmodel for both mm2 and mm3 that references the genmodel for mm1.

I run Eclipse using a Launch Configuration to load the plugins and create model instances: model.one, model.two, and model.three, where model.three references both model.one and model.two.

I tried to run the Acceleo generation using a Launch Configuration pointing at model.three but I could not get the references to resolve; I did put the lines of code specified in the comments of the generated registerPackages method at the bottom of the method and also called EcoreUtil.resolveAll() in the doGenerate method. After struggling with that for a while, I decided to try creating an Acceleo UI Launcher project and start the generation from the running Eclipse instance and that let me make some progress.

I'm guessing that unless I run Eclipse with my plugins installed, the EMF models don't get registered properly even though I call the code to resolve them? Or maybe it can't find the model.one and model.two files? It's probably obvious why my initial attempts didn't work but I just wanted to provide as much context as possible.

By using the UI Launcher, the generation half works. In my Acceleo template, I'm just trying to get the name of the input and output Message specified in model.three (which are referenced from model.one and model.two). The name of the Message referenced from model.two works fine but the name from model.one does not.

This is what my template looks like:
[module generateComponentHpp('http://org.openjaus/jros/bridge/1.0', 'http://openjaus.org/model/1.16', 'http://org.openjaus/jros/ros/1.0')]

[template private generateName(aTransform : bridge::Transform)]
// ERROR!
[/template]

[template private generateName(aTransform : bridge::RosToJausTransform)]
// Model2 --> Model1 //
Input:  Model2: [aTransform.input/]
        Name: [aTransform.input.name/]
        isProxy: [aTransform.input.eIsProxy()/]

Output: Model1: [aTransform.output/]
        Name: [aTransform.output.name/]
        isProxy: [aTransform.output.eIsProxy()/]
[/template]

[template private generateName(aTransform : bridge::JausToRosTransform)]
// Model1 --> Model2
Input: Model1: [aTransform.input/]
        Name: [aTransform.input.name/]
        isProxy: [aTransform.input.eIsProxy()/]

Output: Model2: [aTransform.output/]
        Name: [aTransform.output.name/]
        isProxy: [aTransform.output.eIsProxy()/]

[/template]

[template private generateName(aMessage : model::Message)]
model::Message [aMessage.name/] ([aMessage/])
[/template]

[template private generateName(aMessage : ros::Message)]
ros::Message [aMessage.name/]
[/template]

[template public generateComponentHpp(aBridge : bridge::Bridge)]
[file ('Component.h', false, 'Cp1252')]
#ifndef
#define

[for (aTransform : Transform | aBridge.transforms)]
[generateName(aTransform) /]
[/for]

#endif
[/file]
[/template]



I currently get an IllegalArgumentException being thrown inside EcoreEvaluationEnvironment#navigateProperty when I try to access the 'name' attribute of the Message objects in model.one.

A couple observations that I've made but I don't know if they mean anything:


  1. In the call to navigateProperty that throws the exception, the property variable is:
    org.eclipse.emf.ecore.impl.EAttributeImpl@3db73fe6 (eProxyURI: http://openjaus.org/1.16#//model/Trigger/name)
    


    When I step into
    etarget.eClass().getEAllStructuralFeatures().contains(property)
    the eTarget is the correct type and there is a 'name' attribute but it doesn't match because the incoming property is an eProxyURI.

  2. Going through the call stack when I get the exception in a call to visitAcceleoTemplate I see that the template.body is:

    ['// Model1 --> Model2
    Input:  Model1: ', aTransform.input, '
            Name: ', aTransform.input.null, '
            isProxy: ', aTransform.input.eIsProxy(), '
    
    Output: Model2: ', aTransform.output, '
            Name: ', aTransform.output.name, '
            isProxy: ', aTransform.output.eIsProxy(), '
    ']


    where instead of aTransform.input.name I see aTransform.input.null.


This makes me think something isn't being resolved properly?

I'm working on trying to reproduce with a smaller example but maybe someone has an idea on what I could be doing wrong.

Thanks.

[Updated on: Sat, 22 April 2017 03:15]

Report message to a moderator

Re: IllegalArgumentException in navigateProperty [message #1760088 is a reply to message #1760082] Sat, 22 April 2017 07:16 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5930
Registered: July 2009
Senior Member
Hi

You are either using a very old version of Eclipse or are very lucky: the UI launcher has not worked reliably for quite a few years.

It should not be necessary to install your model plugins. One of EMF's strengths is the ability to use static or dynamic models. Acceleo should work fine with dynamic models.

But beware: IIRC if both dynamic and static models are available, tools/registrations may cause confusion to the code and consequently to the programmer/debugger.

A proxyURI is an absolutely sure sign that something is not registered properly; usually what appears in the proxy. Follow a couple of Acceleo examples and/or read the comments in the Acceleo generated main program carefully.

Regards

Ed Willink
Re: IllegalArgumentException in navigateProperty [message #1760098 is a reply to message #1760088] Sat, 22 April 2017 14:09 Go to previous messageGo to next message
Nicholas Johnson is currently offline Nicholas JohnsonFriend
Messages: 10
Registered: March 2017
Junior Member
Ed,
Thanks for the response.

I should have mentioned the version of Eclipse I'm using in my first post. I'm using Neon.2 (4.6.2) so I guess I got lucky by having the UI Launcher work?

Acceleo is version 3.6.6.

I'm trying to get to a simplified non-working example but I can't reproduce my exact problem as yet. In my simple example, I still have to use the UI Launcher to get the referenced model files to get resolved. If I run the generation using a Launch Configuration from inside the development Eclipse then the referenced objects remain as proxies as seen below.

// One2Two
Input:  One: one.impl.OneImpl@58cbafc2 (eProxyURI: file:/C:/openjaus/ojssdev/runtime-EclipseApplication/example/My.one#//@ones.0), Name: 
        isProxy: true

Output: Two: two.impl.TwoImpl@7161d8d1 (eProxyURI: file:/C:/openjaus/ojssdev/runtime-EclipseApplication/example/My.two#//@twos.1), Name: 
        isProxy: true


// Two2One
Input:  Two: two.impl.TwoImpl@74e28667 (eProxyURI: file:/C:/openjaus/ojssdev/runtime-EclipseApplication/example/My.two#//@twos.0), Name: 
        isProxy: true

Output: One: one.impl.OneImpl@1cf6d1be (eProxyURI: file:/C:/openjaus/ojssdev/runtime-EclipseApplication/example/My.one#//@ones.1), Name: 
        isProxy: true


For the simple example when I run using the UI Launcher, everything gets resolved although I think I'm doing everything the same in the Acceleo code. I feel like there must be something different in the model / genmodel that could be causing the issue? I inherited the Model1 code that I'm trying to use in the real application so there may be something different I have't found as yet.

I'll review the comments and keep trying to get a simplified example that reproduces the issue.

When you say "when both dynamic and static models are available" what do mean? When is the model dynamic vs static? Sorry for the really noob question.



Re: IllegalArgumentException in navigateProperty [message #1760104 is a reply to message #1760098] Sat, 22 April 2017 16:54 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5930
Registered: July 2009
Senior Member
Hi

Dynamic; the *.ecore, *.genmodel defines the model. The *,java is not used.
Static: The genmodelled *.java is used.

"Two: two.impl.TwoImpl@74e28667" suggests that you are using a static model. Probably you haven'y register a rtesource factory for "*.two".

(My advice on Acceleo should be treated cautiously since I stopped using Acceleo 4 years ago.)

Regards

Ed Willink
Previous Topic:add [
Next Topic:sirius table
Goto Forum:
  


Current Time: Mon Jun 25 10:19:25 GMT 2018

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

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

Back to the top