Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] pb with java services(error when i want to call java services)
[Acceleo] pb with java services [message #1754102] Tue, 14 February 2017 14:33 Go to next message
Julien Pourille is currently offline Julien PourilleFriend
Messages: 8
Registered: February 2017
Junior Member
Hy everybody,

I have a big problem and nobody that I know could resolve it.

I juste want to create a Java services class which is called by Acceleo template.

javaservices.mtl
[comment encoding = UTF-8 /]
[module javaservices('http://www.example.org/stanHelp')/]

[query public getDescription(aFunction: Function) : String
	= invoke('org.eclipse.acceleo.module.sample.services.JavaServices', 'getDescription(java.lang.String)', Sequence{aFunction.id})
/]


JavaServices.java
package org.eclipse.acceleo.module.sample.services;

import stanHelp.Function;

public class JavaServices {
	
	public String getDescription(String aFunctionId) {
		return "Description of : " + aFunctionId;
	}

}


generate.mtl
[comment encoding = UTF-8 /]
[module generate('http://www.example.org/stanHelp')]

[import org::eclipse::acceleo::module::sample::services::javaservices /]

[template public generateElement(aMainContainer : MainContainer)]
[comment @main/]

[let aFunction : Function = aMainContainer.functions->first()]
	[file ('test.html', false, 'UTF-8')]
		[getDescription(aFunction)/]
	[/file]
[/let]

[/template]



When I execute this code, i have the following warning :

Invalid result for expression self.invoke('org.eclipse.acceleo.module.sample.services.JavaServices', 'getDescription(stanHelp.Function)', Sequence {arg0}) at line 4 in Module javaservices for query getDescription(Function). Last recorded value of self was org.eclipse.emf.ecore.impl.DynamicEObjectImpl@3cd517a7 (eClass: org.eclipse.emf.ecore.impl.EClassImpl@7bb6c78c (name: MainContainer) (instanceClassName: null) (abstract: false, interface: false)). Problem found while generating the file '/home/ssp/T0164153/workspace_acceleo/org.eclipse.acceleo.module.sample/generatedHtml/test.html'.


And the following error :

One of the parameters' class couldn't be loaded for method getDescription(stanHelp.Function) of class org.eclipse.acceleo.module.sample.services.JavaServices.

Can anyone help me to solve this strange problem?

Thanks
Re: [Acceleo] pb with java services [message #1754348 is a reply to message #1754102] Thu, 16 February 2017 15:40 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Since nobody else is helping, I can give a half reply.

IIRC Acceleo's invoke is very helpful, but requires at least a couple of duplicate declarations to be consistent. Otherwise bang. Again IIRC I raised a Bugzilla to provide a wizard/validation/diagnosis of the nightmare.

I suggest you practice on an invoke that works and then change one thing at a time, on each duplicate, till you get to where you want to.

Regards

Ed Willink
Previous Topic:Incremental for loop
Next Topic:[Acceleo] How to avoid generating lines with only whitespace
Goto Forum:
  


Current Time: Fri Apr 26 09:59:03 GMT 2024

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

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

Back to the top