onModuleLoad() 抛出异常

onModuleLoad() threw an exception

我正在尝试将文本框小部件插入到我网站的 HTML 页面中,但出现以下异常。我在 Eclipse Luna 4.4 中使用 gwt。

    onModuleLoad() threw an exception
    Exception while loading module com.student.appamsoft.client.AppamSoftPvtLtd. See Development Mode for details.
    java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:483) at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:411) at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200) at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526) at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364) at java.lang.Thread.run(Thread.java:745)

java.lang.NullPointerException: null
    at com.student.appamsoft.client.AppamSoftPvtLtd.onModuleLoad(AppamSoftPvtLtd.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:411)
    at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
    at java.lang.Thread.run(Thread.java:745)  

我的 onModuleLoad() 方法内容是:

 TextBox textBox1 = new TextBox(); 
  TextBox textBox2 = new TextBox();

  //add text to text box
  textBox2.setText("Hello World!");

  //set textbox as readonly
  textBox2.setReadOnly(true);

  // Add text boxes to the root panel.
  VerticalPanel panel = new VerticalPanel();
  panel.setSpacing(10);
  panel.add(textBox1);
  panel.add(textBox2);

  RootPanel.get("tb5").add(panel);

我在 Eclipse 中 清理和引用 我的项目后删除了这个错误。这个建议来自@Ovi Faur。 这个错误可能对那些像我这样的 GWT 初学者有帮助。