I have done a simple Hello World GWT example using JSNI. It does nothing but display a message.
This is the code in an EntryPoint class:
public void onModuleLoad() {
// TODO Auto-generated method stub
alert("Hello World!");
}
native void alert(String msg) /*-{
$wnd.alert(msg);
}-*/;
}
I see this Exception:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
Any idea why?
I created the sample GWT project and copied your code into the entry point and it worked fine. I think you have a deeper set up problem. I would look over your *.gwt.xml file and make sure it isn't malformed and check your GWT library references etc. Also open up the Run Configration and make sure it is a Web Application.
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class So implements EntryPoint {
native void alert(String msg) /*-{
$wnd.alert(msg);
}-*/;
/**
* This is the entry point method.
*/
public void onModuleLoad() {
alert("Hello World!");
}
}