Many times when I am working with Guice Injection, I have some mistake(s). Sometimes it's obvious what the issue is, but it seems like Guice is pretty good at swallowing exceptions and gives rather cryptic error messages. Such as the following:
Exception com.google.inject.CreationException: Unable to create injector, see the following errors:
1) [Guice/ErrorInjectingConstructor]: SomeTerminalException: Creation of SomeService client connection pool failed.
at SomeProvider.<init>(SomeOtherProvider.java:39)
while locating SomeProvider
at YourClientModule.configure(YourClientModule.java:10)
\_ installed by: SomeModule SomeProvider
I changed the class names for legal reasons, but the intent is the same.
What are good ways to debug these sort of issues?
When stack traces contain <init>
that means that the execution was in a constructor (see What does <init> signify in a Java exception?). As the error indicates, this happened in line 39 of SomeOtherProvider.java
.