ApplicationConnection Problem


I have a problem when using the ApplicationConnection class to monitor the performance of my application.

Here is my Code :

long startTime = System.currentTimeMillis();
long endTime = System.currentTimeMillis();
ApplicationConnection.getConsole().log("Exec time: " + (endTime-startTime));

When I run it, I catch this exception :

Cause: java.lang.NoClassDefFoundError: com/google/gwt/user/client/Timer
	at com.vaadin.event.ListenerMethod.receiveEvent(
	at com.vaadin.event.EventRouter.fireEvent(
	at com.vaadin.ui.AbstractComponent.fireEvent(
	at com.vaadin.ui.Button.fireClick(
	at com.vaadin.ui.Button.changeVariables(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(
	at javax.servlet.http.HttpServlet.service(
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(
	at org.apache.catalina.core.StandardWrapperValve.invoke(
	at org.apache.catalina.core.StandardContextValve.invoke(
	at org.apache.catalina.core.StandardHostValve.invoke(
	at org.apache.catalina.valves.ErrorReportValve.invoke(
	at org.apache.catalina.core.StandardEngineValve.invoke(
	at org.apache.catalina.connector.CoyoteAdapter.service(
	at org.apache.coyote.http11.Http11Processor.process(
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
	at Source)
Caused by: java.lang.NoClassDefFoundError: com/google/gwt/user/client/Timer
	at com.example.vaadingrid.VaadingridApplication.buttonClick(
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.vaadin.event.ListenerMethod.receiveEvent(
	... 21 more
Caused by: java.lang.ClassNotFoundException:
	at org.apache.catalina.loader.WebappClassLoader.loadClass(
	at org.apache.catalina.loader.WebappClassLoader.loadClass(
	... 27 more

Can anyone help me to find what’s going on ?


ApplicationConnection is a client-side class, and it can be used to log stuff to eg. firebug console in the browser.

When you wish to output debug stuff in the server side just use System.out.println().

Or log4j or whichever logging library you prefer.

Most projects have (or should have) some server side logging system configured as one of the first steps in creating the project. Which one is used often depends on the preferences of the developers and what is used by other libraries used in the project.

Ok, But when can the client-side log be used ?

In my case, I use it on the class which extends Application so I think it should work. Isn’t it ?

Client side classes (and log) are meant to be used on the client side only. While some passive data classes, constants etc. of client side classes might be usable in server side code, all initialization of services (such as logging) is only done on the client. Furthermore, many client side classes contain client specific code, native javascript etc. that cannot work on the server.

Application is purely a server side class, so many other client side classes will not work there.

The client side timer probably consists mostly of browser specific code, and is very unlikely to work on the server. Likewise, the client side log depends on initialization that only works when the code has been compiled into javascript with GWT, and when many other parts of the client side context are configured.

Ok. Sorry, but I’m from GWT and new on Vaadin and I’ve some difficulties to understand when it is a client-side code or a server-side one.

So, as I understand, the code in a class public class MyApplication extends Application will not be compiled as Javascript ? This is only the Vaadin Widget ?

You can take a look at the
architecture description in the book

In short, typically your application lives on the server and only interacts with server side parts of Vaadin. Unless you need custom client side widgets (either from add-ons or developed by yourself), you never need to invoke the GWT compiler - and even if you do use such, you only recompile the widgetset when making changes to the client side widgets.

Vaadin comes with a number of components (layouts, table, button, …) that have a client side part (e.g. VButton) and a server side part (com.vaadin.ui.Button). Vaadin also takes care of the communication between these, the creation of UI widget instances on the browser based on your server side application structure etc.

Very thanks you for your answers. It’s very usefull.