Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT GIN - trivial use-case fails (EventBus)

Tags:

java

gwt

GIN Module:

public class InjectorModule extends AbstractGinModule {
    @Override
    protected void configure() {
        bind(EventBus.class).to(SimpleEventBus.class).in(Singleton.class);
    }
}

Injector:

@GinModules(InjectorModule.class)
public interface Injector extends Ginjector {
    EventBus getEventBus();
}

GWT Module entry point:

public class Module1 implements EntryPoint {
    private final Injector injector = GWT.create(Injector.class);

    public void onModuleLoad() {        
        injector.getEventBus();
    }   
}

Removing call to injector.getEventBus() make everything work fine. Call to injector.getEventBus() causes:

Caused by: java.lang.RuntimeException: Deferred binding failed for 'com.google.web.bindery.event.shared.EventBus' (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.XXX.app.client.InjectorImpl.create_Key$type$com$google$web$bindery$event$shared$EventBus$_annotation$$none$$(InjectorImpl.java:72)
at com.XXX.app.client.InjectorImpl.get_Key$type$com$google$web$bindery$event$shared$EventBus$_annotation$$none$$(InjectorImpl.java:86)
at com.XXX.app.client.InjectorImpl.getEventBus(InjectorImpl.java:7)
at com.XXX.app.client.Module1.onModuleLoad(Module1.java:24)

GWT Development Mode says:

23:58:50.287 [ERROR] Deferred binding result type 'com.google.web.bindery.event.shared.EventBus' should not be abstract
like image 459
Andrey Agibalov Avatar asked Oct 30 '11 06:10

Andrey Agibalov


1 Answers

if you are using gwt 2.4:

There are now two EventBus (one is deprecated) make sure you are using the same type in the injetor and in your entrypoint.

like image 140
Daniel Kurka Avatar answered Sep 25 '22 15:09

Daniel Kurka