I want to start using Guice 3.x to magically inject my java.util.logging.Logger instances.
Here is a snippet of code I am trying to get to work:
@Singleton
public class Main
{
@Inject
private static final Logger logger;
...
}
This doesn't seem to work.
I get Exception in thread "main" java.lang.NullPointerException no matter what scope I use on the declaration.
I added the line super.requestStaticInjection(Main.class); to my module in the configure() method and it started working, but only if I remove the final keyword and make it static Logger logger.
I would prefer to keep the Logger final if at all possible.
What is the proper idiomatic Guice way of doing this?