ApplicationConnection Problem com.google.user.client.Timer

Hi,

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

Here is my Code :


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

When I run it, I catch this exception :


com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.NoClassDefFoundError: com/google/gwt/user/client/Timer
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:507)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
	at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1146)
	at com.vaadin.ui.Button.fireClick(Button.java:366)
	at com.vaadin.ui.Button.changeVariables(Button.java:188)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1087)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:587)
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:265)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:482)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.NoClassDefFoundError: com/google/gwt/user/client/Timer
	at com.example.vaadingrid.VaadingridApplication.buttonClick(VaadingridApplication.java:67)
	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(ListenerMethod.java:487)
	... 21 more
Caused by: java.lang.ClassNotFoundException: com.google.gwt.user.client.Timer
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1516)
	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1361)
	... 27 more

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

Thanks.

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.