Issue 36 in google-gin: GinModule's configure() gets called twice

5 views
Skip to first unread message

codesite...@google.com

unread,
May 5, 2009, 5:28:07 PM5/5/09
to googl...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 36 by marc.dietrichstein: GinModule's configure() gets called
twice
http://code.google.com/p/google-gin/issues/detail?id=36

What steps will reproduce the problem?
(code/error message taken from shybyte's mailinglist post "GinTutorial
doesn't work for me"):
public interface Localization
{
public String MSG_HELLO_WORLD();

}

public class LocalizationImpl implements Localization
{

@Override
public String MSG_HELLO_WORLD()
{
return "Hello World!";
}

}

public class ClientGinModule extends AbstractGinModule
{
@Override
protected void configure()
{
bind(Localization.class).to(LocalizationImpl.class);
}

}

@GinModules(ClientGinModule.class)
public interface LocalizationGinjector extends Ginjector
{
Localization getLocalization();

}

What is the expected output? What do you see instead?
Expected: don't knwo, never seen it ;)
What i got:
In hosted mode I got:

[ERROR] Errors from Guice: Guice creation errors:

1) A binding to prototype.gin.client.Localization was already
configured at com.google.gwt.inject.rebind.LieToGuiceModule
$ImplicitBindingModule.configure(LieToGuiceModule.java:70).
at prototype.gin.client.ClientGinModule.configure
(ClientGinModule.java:21)

1 error
com.google.inject.CreationException: Guice creation errors:

1) A binding to prototype.gin.client.Localization was already
configured at com.google.gwt.inject.rebind.LieToGuiceModule
$ImplicitBindingModule.configure(LieToGuiceModule.java:70).
at prototype.gin.client.ClientGinModule.configure
(ClientGinModule.java:21)

1 error
at
com.google.inject.internal.Errors.throwCreationExceptionIfErrorsExist
(Errors.java:342)
at com.google.inject.InjectorBuilder.initializeStatically
(InjectorBuilder.java:152)
at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:105)
at com.google.inject.Guice.createInjector(Guice.java:92)
at
com.google.gwt.inject.rebind.BindingsProcessor.validateModulesUsingGuice
(BindingsProcessor.java:309)
at com.google.gwt.inject.rebind.BindingsProcessor.process
(BindingsProcessor.java:180)
at com.google.gwt.inject.rebind.GinjectorGeneratorImpl.generate
(GinjectorGeneratorImpl.java:76)
at com.google.gwt.inject.rebind.GinjectorGenerator.generate
(GinjectorGenerator.java:47)
at com.google.gwt.dev.cfg.RuleGenerateWith.realize
(RuleGenerateWith.java:49)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.tryRebind
(StandardRebindOracle.java:113)
at com.google.gwt.dev.shell.StandardRebindOracle$Rebinder.rebind
(StandardRebindOracle.java:62)
at com.google.gwt.dev.shell.StandardRebindOracle.rebind
(StandardRebindOracle.java:172)
at com.google.gwt.dev.shell.ShellModuleSpaceHost.rebind
(ShellModuleSpaceHost.java:114)
at com.google.gwt.dev.shell.ModuleSpace.rebind(ModuleSpace.java:474)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate
(ModuleSpace.java:365)
at com.google.gwt.dev.shell.GWTBridgeImpl.create(GWTBridgeImpl.java:
39)
at com.google.gwt.core.client.GWT.create(GWT.java:91)
at prototype.gin.client.GinPrototype.<init>(GinPrototype.java:32)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance
(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance
(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at com.google.gwt.dev.shell.ModuleSpace.rebindAndCreate
(ModuleSpace.java:373)
at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:318)
at com.google.gwt.dev.shell.BrowserWidget.attachModuleSpace
(BrowserWidget.java:343)
at com.google.gwt.dev.shell.moz.BrowserWidgetMoz.access$100
(BrowserWidgetMoz.java:35)
at com.google.gwt.dev.shell.moz.BrowserWidgetMoz
$ExternalObjectImpl.gwtOnLoad(BrowserWidgetMoz.java:58)
at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native
Method)
at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:
1428)
at
org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2840)
at com.google.gwt.dev.SwtHostedModeBase.processEvents
(SwtHostedModeBase.java:235)
at com.google.gwt.dev.HostedModeBase.pumpEventLoop
(HostedModeBase.java:558)
at com.google.gwt.dev.HostedModeBase.run(HostedModeBase.java:405)
at com.google.gwt.dev.HostedMode.main(HostedMode.java:232)

When compiling to javascript I got:

Compiling module prototype.gin.GinPrototype
Refreshing module from source
Refreshing TypeOracle
Processing types in compilation unit: file:/home/marco/
workspace/GinPrototype/src/prototype/gin/client/
LocalizationGinjector.java
Found type 'LocalizationGinjector'
Resolving annotation '@GinModules
(ClientGinModule.class)'
[ERROR]
java.lang.ClassNotFoundException: prototype.gin.client.ClientGinModule
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:336)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at com.google.gwt.dev.javac.TypeOracleMediator.getClassLiteral
(TypeOracleMediator.java:763)
at
com.google.gwt.dev.javac.TypeOracleMediator.getAnnotationElementValue
(TypeOracleMediator.java:674)
at
com.google.gwt.dev.javac.TypeOracleMediator.createAnnotationInstance
(TypeOracleMediator.java:442)
at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotation
(TypeOracleMediator.java:836)
at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotations
(TypeOracleMediator.java:857)
at
com.google.gwt.dev.javac.TypeOracleMediator.resolveTypeDeclaration
(TypeOracleMediator.java:1384)
at com.google.gwt.dev.javac.TypeOracleMediator.addNewUnits
(TypeOracleMediator.java:389)
at com.google.gwt.dev.javac.TypeOracleMediator.refresh
(TypeOracleMediator.java:417)
at com.google.gwt.dev.javac.CompilationState.refresh
(CompilationState.java:179)
at com.google.gwt.dev.javac.CompilationState.<init>
(CompilationState.java:93)
at com.google.gwt.dev.cfg.ModuleDef.getCompilationState
(ModuleDef.java:264)
at com.google.gwt.dev.Precompile.precompile(Precompile.java:283)
at com.google.gwt.dev.Compiler.run(Compiler.java:170)
at com.google.gwt.dev.Compiler$1.run(Compiler.java:124)
at
com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:
84)
at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger
(CompileTaskRunner.java:78)
at com.google.gwt.dev.Compiler.main(Compiler.java:131)
[ERROR] Unexpected
java.lang.NullPointerException
at
com.google.gwt.dev.javac.TypeOracleMediator.getAnnotationElementValue
(TypeOracleMediator.java:704)
at
com.google.gwt.dev.javac.TypeOracleMediator.createAnnotationInstance
(TypeOracleMediator.java:442)
at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotation
(TypeOracleMediator.java:836)
at com.google.gwt.dev.javac.TypeOracleMediator.resolveAnnotations
(TypeOracleMediator.java:857)
at
com.google.gwt.dev.javac.TypeOracleMediator.resolveTypeDeclaration
(TypeOracleMediator.java:1384)
at com.google.gwt.dev.javac.TypeOracleMediator.addNewUnits
(TypeOracleMediator.java:389)
at com.google.gwt.dev.javac.TypeOracleMediator.refresh
(TypeOracleMediator.java:417)
at com.google.gwt.dev.javac.CompilationState.refresh
(CompilationState.java:179)
at com.google.gwt.dev.javac.CompilationState.<init>
(CompilationState.java:93)
at com.google.gwt.dev.cfg.ModuleDef.getCompilationState
(ModuleDef.java:264)
at com.google.gwt.dev.Precompile.precompile(Precompile.java:283)
at com.google.gwt.dev.Compiler.run(Compiler.java:170)
at com.google.gwt.dev.Compiler$1.run(Compiler.java:124)
at
com.google.gwt.dev.CompileTaskRunner.doRun(CompileTaskRunner.java:
84)
at com.google.gwt.dev.CompileTaskRunner.runWithAppropriateLogger
(CompileTaskRunner.java:78)
at com.google.gwt.dev.Compiler.main(Compiler.java:131)

What version of the product are you using? On what operating system?
Guice Version: svn r937
Gin Version: svn r95
GWT Version: 1.6.4
Plaform: Linux 32 Bit (Ubuntu 9.04)

Please provide any additional information below.
I worked around that issue by adding a check to the implementation of
GinModule.
I'll take shybyte's code as an example:

public class ClientGinModule extends AbstractGinModule
{
private static boolean configured = false;

@Override
protected void configure()
{
if(!configured) {
bind(Localization.class).to(LocalizationImpl.class);
configured = true;
}
}

}

That fixed the duplicate binding errors, but on the other hand made GIN
completly ignore every binding i defined, meaning that Localization would
not be bound to LocalizationImpl although configure() gets called for sure.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

codesite...@google.com

unread,
May 5, 2009, 5:58:27 PM5/5/09
to googl...@googlegroups.com

Comment #1 on issue 36 by shybyte: GinModule's configure() gets called twice
http://code.google.com/p/google-gin/issues/detail?id=36

One remark:
After using an own compile script (instead of the compile button of the
Google Plugin
for Eclipse)
I got the "Guice creation errors" also when compiling to javascript and not
only in
hosted mode.

Reply all
Reply to author
Forward
0 new messages