eggheadonist
Programmer
Hi guys
I have no doubt that I am being complete moron in this case, but I'd appreciate you help in pointing out the obvious.
I am getting a null pointer exception in the contructor for class Foo below in the line logger.debug(..). It seems logger is null. When I move the assignment of "logger = logger.getLogger(MessageService.class)" to the contructor the problem goes away & change to non-static. Why is this is? What is happening here?
Much appreciate.
public class Foo {
private static final Foo instance = new Foo();
static Logger logger = logger.getLogger(MessageService.class);
public Foo() {
logger.debug("constructor called.");
}
public static Foo getInstance() {
logger.debug("getInstance called.");
return instance;
}
I have no doubt that I am being complete moron in this case, but I'd appreciate you help in pointing out the obvious.
I am getting a null pointer exception in the contructor for class Foo below in the line logger.debug(..). It seems logger is null. When I move the assignment of "logger = logger.getLogger(MessageService.class)" to the contructor the problem goes away & change to non-static. Why is this is? What is happening here?
Much appreciate.
public class Foo {
private static final Foo instance = new Foo();
static Logger logger = logger.getLogger(MessageService.class);
public Foo() {
logger.debug("constructor called.");
}
public static Foo getInstance() {
logger.debug("getInstance called.");
return instance;
}