This has to have been asked before, but I haven't had any in searches. I'm looking for a way to catch all client-side obfuscated errors/stack traces and send them to the server for debugging. I did see something about this for javascript using the window.onerror, but I'm looking for a way to do this with GWT, and then display a non-obfuscated stack trace.
Anyone know how to do this? Thanks!
Edit: After working on this for several more hours, I've got the logs going over from GWT to the server via:
GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() {
@Override
public void onUncaughtException(Throwable e) {
log.log(Level.SEVERE, e.getMessage(), e);
}
});
That is using the default Logger included with gwt now. this is the relevent .gwt.xml :
<inherits name="com.google.gwt.logging.Logging" />
<set-property name="gwt.logging.logLevel" value="WARNING" />
<set-property name="gwt.logging.enabled" value="TRUE" />
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" />
<set-property name="gwt.logging.consoleHandler" value="DISABLED" />
<set-property name="gwt.logging.developmentModeHandler" value="ENABLED" />
<set-property name="gwt.logging.systemHandler" value="ENABLED" />
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
<set-property name="gwt.logging.firebugHandler" value="DISABLED" />
<set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true"/>
<set-configuration-property name="compiler.emulatedStack.recordFileNames" value="true"/>
I searched everywhere online, and I even found this which is something from gwt-log, which seems like it's before it was implemented into the GWT SDK: http://code.google.com/p/gwt-log/wiki/GettingStarted#Override_the_default_URL_which_the_RemoteLogger_connects_to
I followed the instructions from the above link, updating the package names and what not. I compile now with the following argument: -deploy war/WEB-INF/deploy/
and this is the relevant part of my web.xml:
<!-- Servlets -->
<servlet>
<servlet-name>RemoteLoggerServlet</servlet-name>
<servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>
<init-param>
<param-name>symbolMaps</param-name>
<param-value>WEB-INF/deploy/**MYAPPNAMEHERE**/symbolMaps/</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>RemoteLoggerServlet</servlet-name>
<url-pattern>/**MYAPPNAMEHERE**/remote_logging</url-pattern>
</servlet-mapping>
The end result is that I get the errors, they are just not de-obfuscated. What am I doing wrong?
GWT has built in support for logging, as detailed in the documentation. There is also support for sending log messages from the client to the server.
You may have to write browser specific code if you want to catch all exceptions. For example, Mozilla have a window.onerror event, however, I don't think this is standard.
The
initParam
is for theRequestFactoryServlet
. With theRemoteLoggingServiceImpl
you're supposed to call itssetSymbolMapsDirectory
method; generally by subclassing the servlet and calling the method from the constructor orinit
method.