google-code-export / google-guice

Automatically exported from code.google.com/p/google-guice
Apache License 2.0
2 stars 1 forks source link

Improve error details for "java.lang.IllegalStateException: not initialized" #277

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Here is a stack trace of one my tests
FAILED CONFIGURATION: @BeforeClass setupTest
java.lang.IllegalStateException: not initialized
    at com.google.common.base.Preconditions.checkState(Preconditions.java:137)
    at
com.google.inject.ClassBindingImpl.acceptTargetVisitor(ClassBindingImpl.java:51)
    at com.google.inject.BindingProcessor.putBinding(BindingProcessor.java:259)
    at com.google.inject.BindingProcessor.access$300(BindingProcessor.java:40)
    at
com.google.inject.BindingProcessor$4.visitUntargetted(BindingProcessor.java:192)
    at
com.google.inject.BindingProcessor$4.visitUntargetted(BindingProcessor.java:126)
    at
com.google.inject.internal.ModuleBinding$1.acceptTargetVisitor(ModuleBinding.jav
a:55)
    at
com.google.inject.internal.ModuleBinding.acceptTargetVisitor(ModuleBinding.java:
117)
    at com.google.inject.BindingProcessor.visitBinding(BindingProcessor.java:126)
    at com.google.inject.BindingProcessor.visitBinding(BindingProcessor.java:40)
    at
com.google.inject.internal.ModuleBinding.acceptVisitor(ModuleBinding.java:109)
    at
com.google.inject.AbstractProcessor.processCommands(AbstractProcessor.java:55)
    at
com.google.inject.InjectorBuilder.buildCoreInjector(InjectorBuilder.java:145)
    at com.google.inject.InjectorBuilder.build(InjectorBuilder.java:102)
    at com.google.inject.Guice.createInjector(Guice.java:92)
    at nrc.brex.ApplicationRunner.init(ApplicationRunner.java:38)
    at nrc.brex.BREXTest.setupTest(BREXTest.java:37)

The "not initialized" is so obscure. It comes from a class that works
perfectly with other modules but when I add more modules I get this error.
Any chances to improve the error reporting for this case?

Original issue reported on code.google.com by erik.put...@nrc-cnrc.gc.ca on 24 Nov 2008 at 4:53

GoogleCodeExporter commented 9 years ago
Just figured out the cause: one of my modules was passed to createInjector but 
it was
also passed in another module to install(<module>).
Any chances this could be caught earlier?

Original comment by erik.put...@nrc-cnrc.gc.ca on 24 Nov 2008 at 5:03

GoogleCodeExporter commented 9 years ago
I believe this was fixed by r692: 
http://code.google.com/p/google-guice/source/detail?r=692
Can you try again with the latest code from SVN?

Original comment by limpbizkit on 24 Nov 2008 at 6:46