我开始在 OS X 10.5.8 上使用 Eclipse 插件来熟悉最新的 Google Web Toolkit。到目前为止,我已经能够启动并运行客户端,这非常棒。
不过,服务器是另一回事。我正在尝试链接到一个 .jar 文件,该文件包含一些我想在服务器 ServiceImpl 类中使用的类,但它似乎已经陷入了 .jar 的先前迭代中 - 我添加了一个方法,重建了 jar ,从 GWT 项目的构建路径(以及导出)的库选项卡中删除了该 jar,并重新包含了该 jar。不走运 - 我仍然得到:
[WARN] Exception while dispatching incoming RPC call
com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract org.gwtapplication.client.LWDocument org.gwtapplication.client.DocumentService.getDocument()' threw an unexpected exception: java.lang.NoSuchMethodError: org.externalmodel.MyReallyValidClass.toSomething()Ljava/lang/String;
at com.google.gwt.user.server.rpc.RPC.encodeResponseForFailure(RPC.java:378)
at com.google.gwt.user.server.rpc.RPC.invokeAndEncodeResponse(RPC.java:581)
...
Caused by: java.lang.NoSuchMethodError: org.externalmodel.MyReallyValidClass.toSomething()Ljava/lang/String;
at org.application.server.DocumentServiceImpl.getDocument(DocumentServiceImpl.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
Eclipse 的代码感知在解析 MyReallyValidClass.toSomething() 调用时没有问题,并且对外部模型类的其他调用也没有错误。有什么线索我应该在哪里寻找吗?
最佳答案
在您的 DocumentServiceImpl
类中,添加以下日志:
System.out.println(Thread.currentThread().getContextClassLoader().getResource("org/externalmodel/MyReallyValidClass.class");
应该告诉你这个 jar 是在哪里捡到的。
关于gwt - GWT 中引发 NoSuchMethod 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3020184/