|IllegalArgumentException in navigateProperty [message #1760082]
||Sat, 22 April 2017 03:11
| Nicholas Johnson
Registered: March 2017
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)]
[template private generateName(aTransform : bridge::RosToJausTransform)]
// Model2 --> Model1 //
Input: Model2: [aTransform.input/]
Output: Model1: [aTransform.output/]
[template private generateName(aTransform : bridge::JausToRosTransform)]
// Model1 --> Model2
Input: Model1: [aTransform.input/]
Output: Model2: [aTransform.output/]
[template private generateName(aMessage : model::Message)]
model::Message [aMessage.name/] ([aMessage/])
[template private generateName(aMessage : ros::Message)]
[template public generateComponentHpp(aBridge : bridge::Bridge)]
[file ('Component.h', false, 'Cp1252')]
[for (aTransform : Transform | aBridge.transforms)]
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:
- 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
the eTarget is the correct type and there is a 'name' attribute but it doesn't match because the incoming property is an eProxyURI.
- 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.
[Updated on: Sat, 22 April 2017 03:15]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02039 seconds