tags:

views:

65

answers:

1

I've been trying to use Grapher on my GIN project. But trying to create an Injector to give the InjectorGrapher has not been working.

Right in the first line of my code:

    Injector injector = Guice.createInjector( new GinModuleAdapter( new MyGinModule() ) );

it crashes with

 Exception in thread "main" java.lang.AssertionError: should never be actually called
at com.google.gwt.inject.rebind.adapter.GwtDotCreateProvider.get(GwtDotCreateProvider.java:43)
at com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:48)
at com.google.inject.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:45)
at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:811)
at com.google.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:42)
at com.google.inject.Scopes$1$1.get(Scopes.java:54)
at com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:48)
at com.google.inject.SingleParameterInjector.inject(SingleParameterInjector.java:42)
at com.google.inject.SingleParameterInjector.getAll(SingleParameterInjector.java:66)
at com.google.inject.ConstructorInjector.construct(ConstructorInjector.java:84)
at com.google.inject.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:111)
at com.google.inject.BoundProviderFactory.get(BoundProviderFactory.java:56)
at com.google.inject.ProviderToInternalFactoryAdapter$1.call(ProviderToInternalFactoryAdapter.java:45)
at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:811)
at com.google.inject.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:42)
at com.google.inject.Scopes$1$1.get(Scopes.java:54)
at com.google.inject.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:48)
at com.google.inject.InjectorBuilder$1.call(InjectorBuilder.java:200)
at com.google.inject.InjectorBuilder$1.call(InjectorBuilder.java:194)
at com.google.inject.InjectorImpl.callInContext(InjectorImpl.java:804)
at com.google.inject.InjectorBuilder.loadEagerSingletons(InjectorBuilder.java:194)
at com.google.inject.InjectorBuilder.injectDynamically(InjectorBuilder.java:176)
at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:113)
at com.google.inject.Guice.createInjector(Guice.java:92)
at com.google.inject.Guice.createInjector(Guice.java:69)
at com.google.inject.Guice.createInjector(Guice.java:59)
at com.me.myself.Grapher.main(Grapher.java:20)

What gives?

A: 

Figured it out: My module had the following line which caused GinModuleAdapter to choke (seems to be a bug):

 bind(Foo.class).asEagerSingleton();

Removing "asEagerSingleton" caused everything to work. But since that's not what I wanted, I converted it into this, which also worked.

@Provides @Singleton
Foo getFoo() {
    return new Foo();
}
Epaga