GinTutorial doesn't work for me

3 views
Skip to first unread message

shybyte

unread,
May 5, 2009, 2:54:04 PM5/5/09
to google-gin
Hi!

I tried to follow the GinTutorial (http://code.google.com/p/google-gin/
wiki/GinTutorial) but I was not able to run even the most simple test
program. I used the latest svn source.

Here are my classes:

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






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)




Do you know the reason and a solution for the problems ???


best regards,
Marco

marc

unread,
May 5, 2009, 5:19:40 PM5/5/09
to google-gin
Hey,

Just wanted to tell you guys that i got the same error yesterday.
The problem seems to be that AbstractGinModule.configure() seems to
get called twice when generating the code.

I worked around that issue by adding a check to the implementation of
GinModule.
I'll take the above 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 (i'll again
use the above example) Localization would not be bound to
LocalizationImpl although configure() gets called for sure.

Guice Version: svn r937
Gin Version: svn r95
GWT Version: 1.6.4
Plaform: Linux 32 Bit (Ubuntu 9.04)

best regards,
marc

marc

unread,
May 5, 2009, 5:29:35 PM5/5/09
to google-gin
i created an issue here: http://code.google.com/p/google-gin/issues/detail?id=36

@shybyte: I used your code/error messages for reference, hope you
don't mind.

best,
marc

shybyte

unread,
May 5, 2009, 5:57:10 PM5/5/09
to google-gin
@marc:
thank you for the issue creating.

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.

best regards,Marco
Reply all
Reply to author
Forward
0 new messages