在客户端代码中使用 RequestContext 接口时,GWT 应用程序在运行时崩溃
我已经与这个问题斗争了 3 天,我想 StackOverflow 是我最后的手段。我不知道为什么它不起作用:(我正在使用 GWT 2.4.0 和 JDK 1.6。
我正在经历 本教程 并陷入了 GWT 应用程序崩溃的困境。如果我提到,应用程序就会崩溃我的客户端代码中甚至没有使用它。我只是尝试引用 RequestFactory - 同样的异常。缺少与 RequestFactory 包相关的内容。我向 GWT 编译器添加了 -logLevel DEBUG,这就是我所拥有的:
DEBUG: Rebinding com.vsezavtra.courierApp.client.ManagerShell.ManagerShellUiBinder.
DEBUG: Checking rule <generate-with class='com.google.web.bindery.requestfactory.gwt.rebind.RequestFactoryGenerator'/>.
ERROR: Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/com/google/web/bindery/requestfactory/shared/Receiver.java'.
ERROR: Unable to find type 'com.vsezavtra.courierApp.client.ManagerShell.ManagerShellUiBinder'.
ERROR: Line 26: The import javax.validation.ConstraintViolation cannot be resolved.
ERROR: Line 79: ConstraintViolation cannot be resolved to a type.
ERROR: Line 81: ConstraintViolation cannot be resolved to a type.
ERROR: Hint: Previous compiler errors may have made this type unavailable.
ERROR: Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly.
ERROR: Deferred binding failed for 'com.vsezavtra.courierApp.client.ManagerShell.ManagerShellUiBinder'; expect subsequent failures.
ERROR: Unable to load module entry point class com.vsezavtra.courierApp.client.courierApp (see associated exception for details). java.lang.RuntimeException: Deferred binding failed for 'com.vsezavtra.courierApp.client.ManagerShell$ManagerShellUiBinder' (did you forget to inherit a required module?)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.vsezavtra.courierApp.client.ManagerShell.<clinit>(ManagerShell.java:15)
at com.vsezavtra.courierApp.client.courierApp.onModuleLoad(courierApp.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
Caused by: com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:595)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.vsezavtra.courierApp.client.ManagerShell.<clinit>(ManagerShell.java:15)
at com.vsezavtra.courierApp.client.courierApp.onModuleLoad(courierApp.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
ERROR: Failed to load module 'courierApp' from user agent 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1' at localhost:10695.
完整日志为 此处。这是我的 GWT XML 文件
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0//EN" "http://google-web-toolkit.googlecode.com/svn/releases/2.0/distro-source/core/src/gwt-module.dtd">
<module rename-to="courierApp">
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.google.web.bindery.requestfactory.RequestFactory"/>
<source path="client"/>
<entry-point class='com.vsezavtra.courierApp.client.courierApp'/>
</module>
主条目 -点类:
package com.vsezavtra.courierApp.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootLayoutPanel;
public class courierApp implements EntryPoint
{
public void onModuleLoad()
{
RootLayoutPanel.get().add(new ManagerShell());
}
}
可绑定 UI 类
package com.vsezavtra.courierApp.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.web.bindery.requestfactory.shared.RequestContext;
public class ManagerShell extends Composite
{
interface ManagerShellUiBinder extends UiBinder<Widget, ManagerShell>
{
}
private static ManagerShellUiBinder uiBinder = GWT.create(ManagerShellUiBinder.class);
public ManagerShell()
{
initWidget(uiBinder.createAndBindUi(this));
}
// if I remove this method everything works :(
public void SetTest(RequestContext test) {}
}
和相应的 XML 文件
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<g:VerticalPanel>
<g:HTMLPanel>
Test!
</g:HTMLPanel>
<g:HTMLPanel>
Test2!
</g:HTMLPanel>
</g:VerticalPanel>
</ui:UiBinder>
因为我还没有服务器端部分。
,最后我的 web.xml 文件只有根“web-app”元素, 应用程序。
如果您还有任何其他问题,请告诉我。我真的不知道我还能做什么:(
I've been fighting with this issue for 3 days and I guess StackOverflow is my last resort. I ran out of ideas why it doesn't work :( I'm using GWT 2.4.0 and JDK 1.6.
I was going through this tutorial and got stuck with crashing GWT app. The app crashes if I mention com.google.web.bindery.requestfactory.shared.RequestContext interface in my client code. I'm not even using it. I just have unused method that takes RequestContext as parameter. I tried referencing RequestFactory - same exception. So I suspect I'm missing something related to RequestFactory package. I added -logLevel DEBUG to GWT compiler and here is what I have:
DEBUG: Rebinding com.vsezavtra.courierApp.client.ManagerShell.ManagerShellUiBinder.
DEBUG: Checking rule <generate-with class='com.google.web.bindery.requestfactory.gwt.rebind.RequestFactoryGenerator'/>.
ERROR: Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/com/google/web/bindery/requestfactory/shared/Receiver.java'.
ERROR: Unable to find type 'com.vsezavtra.courierApp.client.ManagerShell.ManagerShellUiBinder'.
ERROR: Line 26: The import javax.validation.ConstraintViolation cannot be resolved.
ERROR: Line 79: ConstraintViolation cannot be resolved to a type.
ERROR: Line 81: ConstraintViolation cannot be resolved to a type.
ERROR: Hint: Previous compiler errors may have made this type unavailable.
ERROR: Hint: Check the inheritance chain from your module; it may not be inheriting a required module or a module may not be adding its source path entries properly.
ERROR: Deferred binding failed for 'com.vsezavtra.courierApp.client.ManagerShell.ManagerShellUiBinder'; expect subsequent failures.
ERROR: Unable to load module entry point class com.vsezavtra.courierApp.client.courierApp (see associated exception for details). java.lang.RuntimeException: Deferred binding failed for 'com.vsezavtra.courierApp.client.ManagerShell$ManagerShellUiBinder' (did you forget to inherit a required module?)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:53)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.vsezavtra.courierApp.client.ManagerShell.<clinit>(ManagerShell.java:15)
at com.vsezavtra.courierApp.client.courierApp.onModuleLoad(courierApp.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
Caused by: com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:595)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate(ModuleSpace.java:455)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:49)
at com.google.gwt.core.client.GWT.create(GWT.java:97)
at com.vsezavtra.courierApp.client.ManagerShell.<clinit>(ManagerShell.java:15)
at com.vsezavtra.courierApp.client.courierApp.onModuleLoad(courierApp.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:396)
at com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:525)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
at java.lang.Thread.run(Thread.java:662)
ERROR: Failed to load module 'courierApp' from user agent 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1' at localhost:10695.
Full log is here. My application is very small. Here is my GWT XML file
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.0//EN" "http://google-web-toolkit.googlecode.com/svn/releases/2.0/distro-source/core/src/gwt-module.dtd">
<module rename-to="courierApp">
<inherits name='com.google.gwt.user.User'/>
<inherits name="com.google.web.bindery.requestfactory.RequestFactory"/>
<source path="client"/>
<entry-point class='com.vsezavtra.courierApp.client.courierApp'/>
</module>
Main entry-point class:
package com.vsezavtra.courierApp.client;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootLayoutPanel;
public class courierApp implements EntryPoint
{
public void onModuleLoad()
{
RootLayoutPanel.get().add(new ManagerShell());
}
}
Bindable UI class
package com.vsezavtra.courierApp.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
import com.google.web.bindery.requestfactory.shared.RequestContext;
public class ManagerShell extends Composite
{
interface ManagerShellUiBinder extends UiBinder<Widget, ManagerShell>
{
}
private static ManagerShellUiBinder uiBinder = GWT.create(ManagerShellUiBinder.class);
public ManagerShell()
{
initWidget(uiBinder.createAndBindUi(this));
}
// if I remove this method everything works :(
public void SetTest(RequestContext test) {}
}
and corresponding XML file
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder' xmlns:g='urn:import:com.google.gwt.user.client.ui'>
<g:VerticalPanel>
<g:HTMLPanel>
Test!
</g:HTMLPanel>
<g:HTMLPanel>
Test2!
</g:HTMLPanel>
</g:VerticalPanel>
</ui:UiBinder>
and finally my web.xml file has only root "web-app" element because I have no server-side part (yet).
I'm using IntelliJ IDEA 10.5.2 to debug the app.
Please let me know if you have any additional question. I really don't know what else I can do :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您缺少 RequestFactory 所依赖的 javax.validation 实现:
在 RequestFactory 教程中的接线部分 hibernate推荐使用 -validator 以及其他几个依赖项:
It appears you are missing a javax.validation implementation that RequestFactory is dependent on:
In the tutorial for RequestFactory in the Wiring section hibernate-validator is recommended as well as several other dependencies: