2011-06-22 19 views
0

我遇到了非常奇怪的问题,用杜松子酒喷油器在客户端代码返回错误与下面的堆栈跟踪:杜松子酒问题在客户端代码为java.util.List的时候

ERROR: Deferred binding result type 'java.util.List' should not be abstract. 
ERROR: Uncaught exception escaped. java.lang.RuntimeException: Deferred binding failed for 'java.util.List' (did you forget to inherit a required module?) 

它是一个杜松子酒问题或gwt?一般来说,它可以在gwt的客户端使用java.util.list?

这是我如何使用它的一个例子。

public class DataSource 
{ 

private final List<SearchDTO> users; 
private List<String> header = new ArrayList<String>(); 

@Inject 
public DataSource(List<SearchDTO> users) 
{ 
    header.add("Name"); 
    header.add("Age"); 
    header.add("Address"); 
    this.users = users; 
} 

public List<SearchDTO> getUsers() 
{ 
    return users; 
} 

public List<String> getTableHeader() 
{ 
    return header; 
} 

然后我做构造函数注入然后得到这个异常。

以下是完整的堆栈跟踪:

ERROR: Deferred binding result type 'java.util.List' should not be abstract. 
ERROR: Uncaught exception escaped. java.lang.RuntimeException: Deferred binding failed for 'java.util.List' (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.gin.MyGinjectorImpl.create_Key$type$java$util$List$gmgsys$com$webcharge$client$model$SearchDTO$$_annotation$$none$$(MyGinjectorImpl.java:411) 
    at gmgsys.com.webcharge.client.gin.MyGinjectorImpl.get_Key$type$java$util$List$gmgsys$com$webcharge$client$model$SearchDTO$$_annotation$$none$$(MyGinjectorImpl.java:425) 
    at gmgsys.com.webcharge.client.gin.MyGinjectorImpl.create_Key$type$gmgsys$com$webcharge$client$DataSource$_annotation$$none$$(MyGinjectorImpl.java:211) 
    at gmgsys.com.webcharge.client.gin.MyGinjectorImpl.get_Key$type$gmgsys$com$webcharge$client$DataSource$_annotation$$none$$(MyGinjectorImpl.java:222) 
    at gmgsys.com.webcharge.client.gin.MyGinjectorImpl.getDataSource(MyGinjectorImpl.java:11) 
    at gmgsys.com.webcharge.client.MyCellList$3.onSuccess(MyCellList.java:125) 
    at gmgsys.com.webcharge.client.MyCellList$3.onSuccess(MyCellList.java:1) 
    at net.customware.gwt.dispatch.client.DefaultDispatchAsync$1.onSuccess(DefaultDispatchAsync.java:33) 
    at net.customware.gwt.dispatch.client.DefaultDispatchAsync$1.onSuccess(DefaultDispatchAsync.java:1) 
    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:232) 
    at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287) 
    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395) 
    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.MethodAdaptor.invoke(MethodAdaptor.java:103) 
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) 
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167) 
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326) 
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207) 
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132) 
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) 
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) 
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) 
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java) 
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214) 
    at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) 
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) 
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167) 
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281) 
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531) 
    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.rebindAndCreate(ModuleSpace.java:503) 
    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.gin.MyGinjectorImpl.create_Key$type$java$util$List$gmgsys$com$webcharge$client$model$SearchDTO$$_annotation$$none$$(MyGinjectorImpl.java:411) 
    at gmgsys.com.webcharge.client.gin.MyGinjectorImpl.get_Key$type$java$util$List$gmgsys$com$webcharge$client$model$SearchDTO$$_annotation$$none$$(MyGinjectorImpl.java:425) 
    at gmgsys.com.webcharge.client.gin.MyGinjectorImpl.create_Key$type$gmgsys$com$webcharge$client$DataSource$_annotation$$none$$(MyGinjectorImpl.java:211) 
    at gmgsys.com.webcharge.client.gin.MyGinjectorImpl.get_Key$type$gmgsys$com$webcharge$client$DataSource$_annotation$$none$$(MyGinjectorImpl.java:222) 
    at gmgsys.com.webcharge.client.gin.MyGinjectorImpl.getDataSource(MyGinjectorImpl.java:11) 
    at gmgsys.com.webcharge.client.MyCellList$3.onSuccess(MyCellList.java:125) 
    at gmgsys.com.webcharge.client.MyCellList$3.onSuccess(MyCellList.java:1) 
    at net.customware.gwt.dispatch.client.DefaultDispatchAsync$1.onSuccess(DefaultDispatchAsync.java:33) 
    at net.customware.gwt.dispatch.client.DefaultDispatchAsync$1.onSuccess(DefaultDispatchAsync.java:1) 
    at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:232) 
    at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:287) 
    at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:395) 
    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.MethodAdaptor.invoke(MethodAdaptor.java:103) 
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) 
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167) 
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:326) 
    at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:207) 
    at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:132) 
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561) 
    at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269) 
    at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) 
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java) 
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:214) 
    at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
    at java.lang.reflect.Method.invoke(Method.java:597) 
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103) 
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71) 
    at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:167) 
    at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:281) 
    at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:531) 
    at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:352) 
    at java.lang.Thread.run(Thread.java:662) 

感谢。

+0

什么*先前的日志条目*说呢?毕竟,你的异常的根本原因是'引起:com.google.gwt.core.ext.UnableToCompleteException :(查看以前的日志条目)' – Riduidel

回答

2

java.util.List是一个不是具体类的接口,所以GIN不能实例化它。这是错误来自的地方。

另外,GIN应该在哪里得到SearchDTO的列表?

你可能会解决此加给你的GinModule:

@Provides 
List<SearchDTO> getSearchDTOList() { 
    // do something to instantiate the list of SearchDTO.. 
    return listOfSearchDTO; 
} 
+0

感谢彼得,是的,问题在于使用接口List而不是类ArrayList。 :) – brakebg

+0

但是,彼得,我认为杜松子酒能够注入接口,在我的项目中我使用接口MyConst,它扩展了另一个接口Constants(gwt接口用于注册const),我通过构造函数成功注入。 – brakebg

+0

这是因为GIN在接口上调用'GWT.create',并且'Constants'预计会以这种方式创建。对java.util.List没有'replace-with'或'generate-with',所以GWT(而不是实际的GIN)输出错误“Deferred binding result type'java.util.List'should not be抽象。” –

2

关于使用什么:
@Inject
公共数据源(ArrayList的用户){

}

更新
是,一般是可用获得在GWT客户端。
在我的项目中,我没有使用列表作为接口,因为JSON序列化。我不尝试通过GIN注入它,它只是一个想法。
但现在我认为这不是一个好主意,因为它不是使用这种注射剂的方式。

什么时候出现错误,编译?

+0

这是怎么回事? – brakebg

+0

谢谢:)用ArrayList工作替换List。 – brakebg