Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Java wrapper doesn't work(Warnings: service class does not seem to have been exported. Error: Cannot find operation for Integer)
Java wrapper doesn't work [message #754510] Wed, 02 November 2011 16:10 Go to next message
Tomas Balderas is currently offline Tomas Balderas
Messages: 46
Registered: July 2010
Member
Hello. Hope you can help me.

I followed the steps in:

http://wiki.eclipse.org/Acceleo/Getting_Started#Java_services_wrappers

to define a wrapper for a Java service class.

My service class was located in the package ccc.inaoep.mx.acceleo.transformationtool.services of the Acceleo project using the wizards and its code is as follows:

package ccc.inaoep.mx.acceleo.transformationtool.services;

public class ConversionServices {
	public String getBinaryFromInteger(int numberToConvert, int bitLength) {
		int		i;
		int		mask = 1;
		String	binaryString = "";
		
		for (i = 1; i <= bitLength; i++)
			if (i <= Integer.SIZE) {
				if ((numberToConvert & mask) == 0)
					binaryString = "0" + binaryString;
				else
					binaryString = "1" + binaryString;
				
				mask = mask << 1;
			} else {
				if (numberToConvert >= 0)
					binaryString = "0" + binaryString;
				else
					binaryString = "1" + binaryString;
			}
		
		return binaryString;		
	}
}


Then, I added the module file with the wrapper to the package ccc.inaoep.mx.acceleo.transformationtool.services of the Acceleo project. The code for the module (conversionservices) and the wrapper is as follows:

[comment encoding = Cp1252 /]
[module conversionservices('http://www.eclipse.org/uml2/3.0.0/UML')/]

[query public getBinaryFromInteger(arg0 : Integer, arg1 : Integer) : String
	= invoke('ccc.inaoep.mx.acceleo.activity2vhdl.services.ConversionServices',
			 'getBinaryFromInteger(int, int)', Sequence{arg0, arg1}) /]


Then, I get the following warning attached to the invoke operation in the previous query:

The Java service class 'ccc.inaoep.mx.acceleo.transformationtool.services.ConversionServices' from the project 'ccc.inaoep.mx.acceleo.transformationtool' does not seem to have been exported.


Also, when I import ccc.inaoep.mx.acceleo.transformationtool.services.conversionservices in other module
and try to use the query getBinaryFromInteger I get the following error:

Cannot find operation (getBinaryFromInteger()) for the type (Integer)


What can I do to fix this mess? This is my first try with a service class in Acceleo. Please help.

Thanks


/TB
Re: Java wrapper doesn't work [message #754753 is a reply to message #754510] Fri, 04 November 2011 04:10 Go to previous message
Laurent Goubet is currently offline Laurent Goubet
Messages: 1625
Registered: July 2009
Senior Member
Hi,

Quote:
The Java service class 'ccc.inaoep.mx.acceleo.transformationtool.services.ConversionServices' from the project 'ccc.inaoep.mx.acceleo.transformationtool' does not seem to have been exported.


Open the "plugin.xml" file of the project, click the "runtime" tab, hit the "Add..." button beside the left pane ("Exported Packages"), and select the package 'ccc.inaoep.mx.acceleo.transformationtool.services.ConversionServices'.

Quote:
Cannot find operation (getBinaryFromInteger()) for the type (Integer)


You're trying to call the "getBinaryFromInteger" query with a single integer when it expects two. You have something like this :

[someInt.getBinaryFromInteger()/] or [getBinaryFromInteger(someInt)/].

What you need is

[someInt.getBinaryFromInteger(anotherInt)/] or [getBinaryFromInteger(someInt, anotherInt)/].

Laurent Goubet
Obeo
Previous Topic:Acceleo: Get an Activity from Operation
Next Topic:[Acceleo] Prefix of used metamodels
Goto Forum:
  


Current Time: Sat Aug 30 12:28:38 EDT 2014

Powered by FUDForum. Page generated in 0.01425 seconds