Can't get a call from hand writen JavaScript to call Java-method.


From Vaadin pages / foorum and google tutorials I have understood that I should be able to call Java-function from hand writen JavaScript using this method:

I have done a class as tutorial tells:

package com.example.vaadin;

public class MyUtilityClass {

public static int computeLoanInterest() {	
	return 10;

public static native void exportStaticMethod() /*-{
$wnd.computeLoanInterest =


I call MyUtilityClass.exportStaticMethod from Vaadin applications init()-method.

When I start Vaadin application I get following error:

SEVERE: Servlet.service() for servlet Vaadin Application threw exception
java.lang.UnsatisfiedLinkError: com.example.vaadin.MyUtilityClass.exportStaticMethod()

I havent been able to find solution for my problem.


You can only call Java methods that are compiled to the client side part of the application (GWT widgetset). And GWT expects all client side classes to be found under package named *.client, with the widgetset XML file residing before in the hierarchy:


Thanks for the reply and pointing me to right direction.
Now Im able to get my classes compiled atleast. But Im still having problem. I cant get call to my Client side Java method to work from hand writen JavaScript.

I used Vaadin Eclipse plugins “Create Widget” functionality. And named my widget to MyComponent.

Now I have client side class and server side class
I added previously mentioned exportStaticMethod()- and computeLoanInterest()- methods to VMyComponenet class and call exportStaticMethod()-method from VMyComponet classes onLoad()-method.

Widget works and it counts my clicks and shos the count at client side.

From hand writen JavaScript Im trying to call computeLoanInterest() just by running alert(‘Works:’+computeLoanInterest() )

Im doing something wrong but dont know what. Im totally newbie when it comes to Vaadin. Any fast ideas what Im doing wrong?

I tried with this approach, didnt get it to work either:

Vaadin foorum: custom component with publishing API to invoke from javascript


Now it works. My problem was that I had added my Widget to TabSheets second tab. And When Vaadin application was loaded I tried to call My Widgets method from JavaScript at applications init metod.

Because widget was at second tab it was never loaded during application init, thus method was never registered. I moved widget to first page of my application and now it got loaded before I called its function from JavaScript.

Thanks again for pointing me to right direction.