Gwt Remote Logging Could Not Log Throwable Stacktrace?
Solution 1:
Consider logging exception stack traces:
<set-property name="compiler.stackMode"
value="emulated" />
<set-configuration-property name="compiler.emulatedStack.recordLineNumbers"
value="true"/>
<set-configuration-property name="compiler.emulatedStack.recordFileNames"
value="true"/>
stacktrace and exception handling are following as:
Solution 2:
You are getting the exception when casting the SerializableThrowable from the client.impl library to the core.shared library. It seems like you just want the issue to be written to the log as a string. I've never used this class (just reading from the documentation), have you tried the following ...
// Throwable throwable
LogRecord lr = newLogRecord(Level.SEVERE, throwable.toString());
logger.log(lr);
or
// Throwable throwable
LogRecord lr = newLogRecord(Level.SEVERE, throwable.getMessage());
logger.log(lr);
if this doesn't work, you may find the following links helpful:
http://www.summa-tech.com/blog/2012/06/11/7-tips-for-exception-handling-in-gwt/
Note that in the URL above, in Tip 4, the author sets his program up identically to yours. But he cautions in the last paragraph that ....
"[Log exceptions on the server] seems straight-forward, right? Be careful! First, not all exceptions are serializable or follow the rules of serializable (ugh!). For example, GWT’s JavascriptException inherits Serializable, but doesn’t implement a public no-arg constructor, so when you try to send this over the wire via your RPC, a run-time Serialization exception is thrown. And since this exception would be thrown inside your exception handler, it would effectively swallowed. Second, the stack trace within an exception is transient, and so [it] is lost from client to server (so if you need it on the server side, send it as a separate parameter). Which leads me to the next tip…"
In the paragraph he states the exact original problem you were having - not all exceptions are serializable so a Serialization exception may be thrown (which might also explain why the throwable object is null when you are trying to ouput the thrown error's message from the AsyncCallback class' onFailure method). Then go on to read tip number 5 and 6.
These links may also be useful ...
Best Practices for GWT services exceptions logging
http://cleancodematters.com/2011/05/29/improved-exceptionhandling-with-gwts-requestfactory/
Solution 3:
Looking at the error you get, it seems that your GWT app is sending instances of com.google.gwt.core.client.impl.SerializableThrowable
but your server is expecting instances of com.google.gwt.core.shared.SerializableThrowable
.
In our project we are still using GWT 2.5 and the class we have in the SDK is the first one.
It seems that GWT 2.6 introduced the second one and deprecated the other. Maybe your client and your server are not on the exact same version of GWT? Or you have client code that uses the wrong SerializableThrowable somehow.
Also, here are two properties I noticed that we have but you don't mention in the GWT config:
<set-property name="compiler.stackMode" value="emulated" />
<set-configuration-property name="compiler.emulatedStack.recordLineNumbers" value="true" />
Post a Comment for "Gwt Remote Logging Could Not Log Throwable Stacktrace?"