Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] [new edit] "argument type mismatch" when calling a Java Service Wrapper
[Acceleo] [new edit] "argument type mismatch" when calling a Java Service Wrapper [message #1384432] Thu, 29 May 2014 01:09 Go to next message
daniele Mising name is currently offline daniele Mising nameFriend
Messages: 48
Registered: July 2009
Member
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

Re: [Acceleo] Invalid result for expression self.invoke when calling a Java Service Wrapper [message #1384631 is a reply to message #1384432] Thu, 29 May 2014 18:56 Go to previous messageGo to next message
daniele Mising name is currently offline daniele Mising nameFriend
Messages: 48
Registered: July 2009
Member
If a define the function to accept a parameter of type Object (OclAny for the query) and then try to cast the java.lang.Object in myPackage.Send, I get this error:

Caused by: java.lang.ClassCastException: org.eclipse.emf.ecore.impl.DynamicEObjectImpl cannot be cast to myPackage.Send
Re: [Acceleo] Invalid result for expression self.invoke when calling a Java Service Wrapper [message #1384664 is a reply to message #1384631] Fri, 30 May 2014 07:10 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7649
Registered: July 2009
Senior Member
Hi

DynamicEObjectImpl is not a Send so it looks like you didn't follow the
comments in the generated main template to register your package.

Regards

Ed Willink

On 29/05/2014 19:56, daniele Mising name wrote:
> If a define the function to accept a parameter of type Object (OclAny
> for the query) and then try to cast the java.lang.Object in
> myPackage.Send, I get this error:
>
> Caused by: java.lang.ClassCastException:
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl cannot be cast to
> myPackage.Send
Previous Topic:Difference in Compiler Output
Next Topic:"Generation Fail" --> problème de méta model
Goto Forum:
  


Current Time: Sun Mar 03 06:28:12 GMT 2024

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

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

Back to the top