Hello, this is my problem:
I have a custom-model defined in EMF. From this model, I want to generate code with Acceleo. I need to call a java function on an object of type "Send" of my model. But I can't call a java wrapping service in Acceleo because it doesn't recognize the parameter type.
This is an easy example that gives the error: the main calls a query stored in Services.mtl, that calls the java service that just return the name of an object "Send"
Main.mtl
[file ('system.P', false, 'UTF-8')]
[for (t : Send | aSystemBehavior.transitions)) ]
[getName(t)/]
[/for]
[/file]
Services.mtl
[query public getName(arg0 : Send) : String
= invoke('myPackage.Services', 'getName(myPackage.Send)', Sequence{arg0})
/]
Services.java
public class Services
{
public String getName(Send t)
{return t.getName();}
}
The Error Log shows:
Invalid result for expression self.invoke('myPakage.Services', 'getName(myPakage.Send)', Sequence {arg0}) at line 0 in Module services for query getName(Send).
Last recorded value of self was org.eclipse.emf.ecore.impl.DynamicEObjectImpl@1f00eb36
(eClass: org.eclipse.emf.ecore.impl.EClassImpl@2c2aade3 (name: Send)
(instanceClassName: null)
(abstract: false, interface: false)).
Problem found while generating the file system.P
and
org.eclipse.acceleo.engine.AcceleoEvaluationException: argument type mismatch
at org.eclipse.acceleo.engine.internal.environment.AcceleoLibraryOperationVisitor.invoke(AcceleoLibraryOperationVisitor.java:1215)
at org.eclipse.acceleo.engine.internal.environment.AcceleoLibraryOperationVisitor.callNonStandardOperation(AcceleoLibraryOperationVisitor.java:133)
.....
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.acceleo.engine.internal.environment.AcceleoLibraryOperationVisitor.invoke(AcceleoLibraryOperationVisitor.java:1207)
... 39 more
If I use a String or primitive types as parameter type instead of Send, everything works fine.
[Updated on: Thu, 29 May 2014 20:28]
Report message to a moderator