GWT问题,GWT.create(SomeClass.class)抛出异常
我有一个 gwt 项目并使用方法 GWT.create(SomeClass.class) 抛出异常。 例外是:
Loading module: Webcharge
Top URL: http://127.0.0.1:8888/Webcharge.html?gwt.codesvr=127.0.0.1:9997
User agent: Chrome
Remote host: wsta1:39330
Tab key:
Session key: v2aC'2^b3!lQgZS6
DEBUG: Validating newly compiled units.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/com/google/gwt/editor/client/EditorDriver.java'.
ERROR: Line 97: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/com/google/gwt/editor/client/impl/BaseEditorDriver.java'.
ERROR: Line 67: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/com/google/gwt/editor/client/impl/SimpleViolation.java'.
ERROR: Line 40: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/com/google/gwt/editor/client/testing/MockSimpleBeanEditorDriver.java'.
ERROR: Line 108: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?.
ERROR: Errors in 'file:/home/devel/webcharge/webapp-gwt/src/gmgsys/com/webcharge/client/DataSource.java'.
ERROR: Line 15: No source code is available for type gmgsys.com.webcharge.model.MyUser; did you forget to inherit a required module?.
ERROR: Errors in 'file:/home/devel/webcharge/webapp-gwt/src/gmgsys/com/webcharge/client/MainPanel.java'.
ERROR: Line 124: No source code is available for type gmgsys.com.webcharge.model.MyUser; did you forget to inherit a required module?.
ERROR: Errors in 'file:/home/devel/webcharge/webapp-gwt/src/gmgsys/com/webcharge/client/MyTable.java'.
ERROR: Errors in 'file:/home/devel/webcharge/webapp-gwt/src/gmgsys/com/webcharge/client/WebchargeService.java'.
ERROR: Errors in 'file:/home/devel/webcharge/webapp-gwt/src/gmgsys/com/webcharge/client/WebchargeServiceAsync.java'.
ERROR: Line 46: No source code is available for type gmgsys.com.webcharge.model.MyUser; did you forget to inherit a required module?.
ERROR: Line 13: No source code is available for type gmgsys.com.webcharge.model.MyUser; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/javax/validation/super/javax/validation/Configuration.java'.
ERROR: Line 12: No source code is available for type gmgsys.com.webcharge.model.MyUser; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/javax/validation/ConstraintViolationException_CustomFieldSerializer.java'.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/javax/validation/super/javax/validation/MessageInterpolator.java'.
ERROR: Line 93: No source code is available for type javax.validation.TraversableResolver; did you forget to inherit a required module?.
ERROR: Line 105: No source code is available for type javax.validation.ConstraintValidatorFactory; did you forget to inherit a required module?.
ERROR: Line 202: No source code is available for type javax.validation.ValidatorFactory; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/javax/validation/super/javax/validation/constraints/Pattern.java'.
ERROR: Line 30: No source code is available for type javax.validation.ConstraintViolationException; did you forget to inherit a required module?.
ERROR: Line 39: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?.
ERROR: Line 66: No source code is available for type javax.validation.metadata.ConstraintDescriptor<T>; did you forget to inherit a required module?.
ERROR: Line 75: No source code is available for type javax.validation.Payload; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/javax/validation/super/javax/validation/spi/ConfigurationState.java'.
ERROR: Line 93: No source code is available for type javax.validation.ConstraintValidatorFactory; did you forget to inherit a required module?.
ERROR: Line 107: No source code is available for type javax.validation.TraversableResolver; did you forget to inherit a required module?.
DEBUG: Rebinding com.google.gwt.core.client.impl.SchedulerImpl.
DEBUG: Checking rule <generate-with class='com.google.gwt.editor.rebind.SimpleBeanEditorDriverGenerator'/>.
WARN: Detected warnings related to 'com.google.gwt.editor.client.SimpleBeanEditorDriver'. Are validation-api-<version>.jar and validation-api-<version>-sources.jar on the classpath?.
INFO: Specify -logLevel DEBUG to see all errors..
WARN: Unknown type 'com.google.gwt.editor.client.SimpleBeanEditorDriver' specified in deferred binding rule.
DEBUG: Rebinding gmgsys.com.webcharge.client.WebchargeService.
DEBUG: Checking rule <generate-with class='com.google.gwt.user.rebind.ui.ImageBundleGenerator'/>.
ERROR: Unable to find type 'gmgsys.com.webcharge.client.WebchargeService'.
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 'gmgsys.com.webcharge.client.WebchargeService'; expect subsequent failures.
ERROR: Unable to load module entry point class gmgsys.com.webcharge.client.Webcharge (see associated exception for details). java.lang.RuntimeException: Deferred binding failed for 'gmgsys.com.webcharge.client.WebchargeService' (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:98)
at gmgsys.com.webcharge.client.WebchargeService$App.<clinit>(WebchargeService.java:20)
at gmgsys.com.webcharge.client.MainPanel.<init>(MainPanel.java:22)
at gmgsys.com.webcharge.client.Webcharge.onModuleLoad(Webcharge.java:63)
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:193)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
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:98)
at gmgsys.com.webcharge.client.WebchargeService$App.<clinit>(WebchargeService.java:20)
at gmgsys.com.webcharge.client.MainPanel.<init>(MainPanel.java:22)
at gmgsys.com.webcharge.client.Webcharge.onModuleLoad(Webcharge.java:63)
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:193)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
at java.lang.Thread.run(Thread.java:662)
ERROR: Failed to load module 'Webcharge' from user agent 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24' at wsta1:39330.
和一些解释
Webcharge 是我的项目入口点,正如您在堆栈跟踪中看到的,抛出异常 (WebchargeService.java:21) ,在那一行我有 private static WebchargeServiceAsync ourInstance = GWT.create(WebchargeService.class);
WebchargeService
@RemoteServiceRelativePath(value = "WebchargeService")
public interface WebchargeService extends RemoteService
{
String getMessage(MyUser user);
List<MyUser> getUserList();
List<MyUser> updateUser(MyUser user) throws Exception;
List<MyUser> selectByName(String name);
String getMessage(String msg);
public static class App
{
private static WebchargeServiceAsync ourInstance = GWT.create(WebchargeService.class);
public static synchronized WebchargeServiceAsync getInstance()
{
return ourInstance;
}
}
}
和 WebchargeServiceAsync 的代码
public interface WebchargeServiceAsync
{
void getMessage(String msg, AsyncCallback<String> async);
void getMessage(MyUser user, AsyncCallback<String> async);
void getUserList(AsyncCallback<List<MyUser>> async);
void updateUser(MyUser user, AsyncCallback<List<MyUser>> async);
void selectByName(String name, AsyncCallback<List<MyUser>> async);
}
欢迎任何帮助:)
谢谢。
i have a gwt project and using method GWT.create(SomeClass.class) throw exception.
The exception is :
Loading module: Webcharge
Top URL: http://127.0.0.1:8888/Webcharge.html?gwt.codesvr=127.0.0.1:9997
User agent: Chrome
Remote host: wsta1:39330
Tab key:
Session key: v2aC'2^b3!lQgZS6
DEBUG: Validating newly compiled units.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/com/google/gwt/editor/client/EditorDriver.java'.
ERROR: Line 97: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/com/google/gwt/editor/client/impl/BaseEditorDriver.java'.
ERROR: Line 67: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/com/google/gwt/editor/client/impl/SimpleViolation.java'.
ERROR: Line 40: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/com/google/gwt/editor/client/testing/MockSimpleBeanEditorDriver.java'.
ERROR: Line 108: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?.
ERROR: Errors in 'file:/home/devel/webcharge/webapp-gwt/src/gmgsys/com/webcharge/client/DataSource.java'.
ERROR: Line 15: No source code is available for type gmgsys.com.webcharge.model.MyUser; did you forget to inherit a required module?.
ERROR: Errors in 'file:/home/devel/webcharge/webapp-gwt/src/gmgsys/com/webcharge/client/MainPanel.java'.
ERROR: Line 124: No source code is available for type gmgsys.com.webcharge.model.MyUser; did you forget to inherit a required module?.
ERROR: Errors in 'file:/home/devel/webcharge/webapp-gwt/src/gmgsys/com/webcharge/client/MyTable.java'.
ERROR: Errors in 'file:/home/devel/webcharge/webapp-gwt/src/gmgsys/com/webcharge/client/WebchargeService.java'.
ERROR: Errors in 'file:/home/devel/webcharge/webapp-gwt/src/gmgsys/com/webcharge/client/WebchargeServiceAsync.java'.
ERROR: Line 46: No source code is available for type gmgsys.com.webcharge.model.MyUser; did you forget to inherit a required module?.
ERROR: Line 13: No source code is available for type gmgsys.com.webcharge.model.MyUser; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/javax/validation/super/javax/validation/Configuration.java'.
ERROR: Line 12: No source code is available for type gmgsys.com.webcharge.model.MyUser; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/javax/validation/ConstraintViolationException_CustomFieldSerializer.java'.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/javax/validation/super/javax/validation/MessageInterpolator.java'.
ERROR: Line 93: No source code is available for type javax.validation.TraversableResolver; did you forget to inherit a required module?.
ERROR: Line 105: No source code is available for type javax.validation.ConstraintValidatorFactory; did you forget to inherit a required module?.
ERROR: Line 202: No source code is available for type javax.validation.ValidatorFactory; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/javax/validation/super/javax/validation/constraints/Pattern.java'.
ERROR: Line 30: No source code is available for type javax.validation.ConstraintViolationException; did you forget to inherit a required module?.
ERROR: Line 39: No source code is available for type javax.validation.ConstraintViolation<T>; did you forget to inherit a required module?.
ERROR: Line 66: No source code is available for type javax.validation.metadata.ConstraintDescriptor<T>; did you forget to inherit a required module?.
ERROR: Line 75: No source code is available for type javax.validation.Payload; did you forget to inherit a required module?.
ERROR: Errors in 'jar:file:/home/devel/Downloads/gwt-2.3.0/gwt-user.jar!/javax/validation/super/javax/validation/spi/ConfigurationState.java'.
ERROR: Line 93: No source code is available for type javax.validation.ConstraintValidatorFactory; did you forget to inherit a required module?.
ERROR: Line 107: No source code is available for type javax.validation.TraversableResolver; did you forget to inherit a required module?.
DEBUG: Rebinding com.google.gwt.core.client.impl.SchedulerImpl.
DEBUG: Checking rule <generate-with class='com.google.gwt.editor.rebind.SimpleBeanEditorDriverGenerator'/>.
WARN: Detected warnings related to 'com.google.gwt.editor.client.SimpleBeanEditorDriver'. Are validation-api-<version>.jar and validation-api-<version>-sources.jar on the classpath?.
INFO: Specify -logLevel DEBUG to see all errors..
WARN: Unknown type 'com.google.gwt.editor.client.SimpleBeanEditorDriver' specified in deferred binding rule.
DEBUG: Rebinding gmgsys.com.webcharge.client.WebchargeService.
DEBUG: Checking rule <generate-with class='com.google.gwt.user.rebind.ui.ImageBundleGenerator'/>.
ERROR: Unable to find type 'gmgsys.com.webcharge.client.WebchargeService'.
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 'gmgsys.com.webcharge.client.WebchargeService'; expect subsequent failures.
ERROR: Unable to load module entry point class gmgsys.com.webcharge.client.Webcharge (see associated exception for details). java.lang.RuntimeException: Deferred binding failed for 'gmgsys.com.webcharge.client.WebchargeService' (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:98)
at gmgsys.com.webcharge.client.WebchargeService$App.<clinit>(WebchargeService.java:20)
at gmgsys.com.webcharge.client.MainPanel.<init>(MainPanel.java:22)
at gmgsys.com.webcharge.client.Webcharge.onModuleLoad(Webcharge.java:63)
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:193)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
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:98)
at gmgsys.com.webcharge.client.WebchargeService$App.<clinit>(WebchargeService.java:20)
at gmgsys.com.webcharge.client.MainPanel.<init>(MainPanel.java:22)
at gmgsys.com.webcharge.client.Webcharge.onModuleLoad(Webcharge.java:63)
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:193)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:510)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352)
at java.lang.Thread.run(Thread.java:662)
ERROR: Failed to load module 'Webcharge' from user agent 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57 Safari/534.24' at wsta1:39330.
and a few explanation
Webcharge is my entry point for the project, as you can see in the stacktrace the exception is thrown (WebchargeService.java:21) where at that line i have
private static WebchargeServiceAsync ourInstance = GWT.create(WebchargeService.class);
WebchargeService
@RemoteServiceRelativePath(value = "WebchargeService")
public interface WebchargeService extends RemoteService
{
String getMessage(MyUser user);
List<MyUser> getUserList();
List<MyUser> updateUser(MyUser user) throws Exception;
List<MyUser> selectByName(String name);
String getMessage(String msg);
public static class App
{
private static WebchargeServiceAsync ourInstance = GWT.create(WebchargeService.class);
public static synchronized WebchargeServiceAsync getInstance()
{
return ourInstance;
}
}
}
and the code for WebchargeServiceAsync
public interface WebchargeServiceAsync
{
void getMessage(String msg, AsyncCallback<String> async);
void getMessage(MyUser user, AsyncCallback<String> async);
void getUserList(AsyncCallback<List<MyUser>> async);
void updateUser(MyUser user, AsyncCallback<List<MyUser>> async);
void selectByName(String name, AsyncCallback<List<MyUser>> async);
}
Any help is welcome :)
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
今天我遇到了完全相同的问题。这是解决方案:
文件:validation-api-1.0.0.GA-sources.jar和validation-api-1.0.0.GA.jar可以在可下载的gwt sdk中找到,在编译时应该位于您的类路径中或执行开发模式。源 jar 至关重要,因此 Peter 的解决方案不起作用。
today I had exactly the same problem. here is the solution:
the files: validation-api-1.0.0.GA-sources.jar and validation-api-1.0.0.GA.jar which can be found in the downloadable gwt sdk should be in your classpath when compiling or executing dev-mode. the sources jar is critical, therefore Peter's solution did not work.
GWT 2.3 需要 javax.validation jar: http://mvnrepository.com /artifact/javax.validation/validation-api/1.0.0.GA
下载它并将其添加到您的项目 lib 文件夹中。
GWT 2.3 requires javax.validation jar: http://mvnrepository.com/artifact/javax.validation/validation-api/1.0.0.GA
Download it and add it to your project lib folder.
我遇到了类似的问题,这是由于打字错误
错误(抛出强制转换异常):
正确(添加...异步):
I had similar problem which was caused by typo
Wrong (throws Cast Exception):
Correct (added ...Async):
正如已经说明的异常:您是否忘记继承所需的模块?
例如,“MyUser”可用吗?
as the exception already stated: did you forget to inherit a required module?
For example, is the "MyUser" available?
阅读此问题并查看答案后,解决方案如下:
如果您通过复制新的 gwt 文件手动更新库:(我们很多人都这样做)
复制您的验证 API -1.0.0.GA.jar 和validation-api-1.0.0.GA-sources.jar 到 gwt-dependencies 目录中。
从类路径中删除所有 VAADIN_DOWNLOAD 变量。
使用以下条目将以下变量添加到项目的构建路径:
gwt-dev.jar、gwt-user.jar、validation-api-1.0.0.GA.jar 和validation-api-1.0.0.GA-sources.jar。
编译小部件集
如果您没有通过复制新的gwt文件手动更新您的库:
After reading this question and looking at the answers, here's the solution:
If you updated your libraries manually by copying the new gwt files : (which a lot of us did)
copy your validation-api-1.0.0.GA.jar and validation-api-1.0.0.GA-sources.jar into the gwt-dependencies directory.
remove all VAADIN_DOWNLOAD variables from your classpath.
Add the following variables to the project's build path with the following entries:
gwt-dev.jar, gwt-user.jar,validation-api-1.0.0.GA.jar AND validation-api-1.0.0.GA-sources.jar.
Compile widgetset
If you haven't updated your libraries manually by copying the new gwt files :