NPE with VConsole

Hi,

I am trying to use the VConsole to print debug statements. Yet, when I run my application I get a null pointer exception:

java.lang.NullPointerException
com.vaadin.terminal.gwt.client.VConsole.log(VConsole.java:57)

It does not matter if I use ‘?debug’ in the URL or not. It always happen.

I have checked the source code and it seems like the following method is never called on VConsole:

static void setImplementation(Console console) {
    impl = console;
}

I can’t find any information explaining how to use/configure VConsole… is there any available?

Thanks!

Hmm… so you are trying to use the client-side part of the
Console add-on
? It is not designed to be used that way.

Instead you should use the org.vaadin.console.Console class in your application.

However, if you want to use only client-side part in yout GWT application, you should use the org.vaadin.console.client.ui.TextConsole class in the same package. It is the GWT widget that the VConsole uses internally.

VConsole is automatically configured in ApplicationConfiguration when the application starts and takes into account if the application is in debug mode or not. I do not see from the code how “impl” could be null unless you are trying to log from a static block that is executed before the widgetset has started.

I have been trying to log something in the Debug console form the init() method. May be this was too early.

I have a found a workaround: getMainWindow().showNotification(…); It displays the debug messages I need.

It is unclear to me how and when the Console can be used. Can it be used within the init() method? Should one call Window.setImmediate(true) before? I could not find clear documentation about it (code example).

Thanks!

Hi,

The VConsole class is for client side logging and it doens’t work on the server side. For server side logging you should use some Java logging library. E.g. java.util.logging (Vaadin since 6.5 uses this), Slf4j or Log4j are such libraries. Book of Vaadin has
a section about logging
.