0

I met very weird problem, using Gin injector in the client code return error with the following stack trace:

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?) 

Is it a gin issue or gwt ? In general is it available using java.util.list in the client side in gwt?

Here is an example how i use it.

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;
}

and then i do constructor injection and then got this exception.

Here is the full stack trace:

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)

Thanks.

brakebg
  • 414
  • 3
  • 11
  • 24
  • What do *previous log entries* say ? After all, the root cause of your exception is `Caused by: com.google.gwt.core.ext.UnableToCompleteException: (see previous log entries)` – Riduidel Jun 22 '11 at 12:20

2 Answers2

2

what about using:
@Inject
public DataSource(ArrayList users) {

}

Update
Yes, in general is it available using java.util.List in the GWT client.
In my Project I am not using List as interface, because of JSON Serialization. I don't try injecting it via GIN, it was only an idea.
But now I think it is not a good idea, cuase it is not the way using this injection.

When do you get the error, compiling ?

oliholz
  • 7,447
  • 2
  • 43
  • 82
2

java.util.List is an interface not a concrete class, so GIN can not instantiate it. This is where the error is coming from.

Also, where is GIN supposed to get a list of SearchDTO?

You might work around this by adding this to your GinModule:

@Provides
List<SearchDTO> getSearchDTOList() {
    // do something to instantiate the list of SearchDTO..
    return listOfSearchDTO;
}
Peter Knego
  • 79,991
  • 11
  • 123
  • 154
  • Thanks Peter, yes the problem was in using interface List instead of class ArrayList. :) – brakebg Jun 22 '11 at 13:44
  • But Peter, i think Gin is able to inject interface, in my project i m using a interface MyConst which extend another interface Constants (gwt interface for registering const)which i inject successfully by constructor. – brakebg Jun 22 '11 at 13:48
  • This is because GIN calls `GWT.create` on the interface, and `Constants` is expected to be created that way. There's no `replace-with` or `generate-with` for a `java.util.List`, so GWT (and not GIN, actually) outputs the error "Deferred binding result type 'java.util.List' should not be abstract." – Thomas Broyer Jun 22 '11 at 15:00
  • @Thomas - thanks for the explanation on GWT versus GIN instantiating interfaces. This could be handy in some situations. – Peter Knego Jun 22 '11 at 15:40
  • Note that this is going to change in future releases of GIN: thanks to changes in GWT, GIN will be able to know whether a particular interface, abstract class, or class with no injectable or zero-arg constructor will trigger some deferred binding rule. It will then be able to detect the `List` case here and log its own, more detailed, error. – Thomas Broyer Jun 22 '11 at 16:04