Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
349 views
in Technique[技术] by (71.8m points)

java - Why is Tomcat unable to show the actual stack trace?

Using GWT, I have deployed my server into Tomcat. This works fine, but when GWT throws an exception, a Popup shows the client the stack trace of the exception.

In dev mode, this works fine. In Tomcat, I get the below stack trace.

Why and how do you fix this?

Unknown.Le(StackTraceCreator.java:168)
Unknown.Jd(StackTraceCreator.java:421)
Unknown.NT(Exception_FieldSerializer.java:16)
Unknown.g1(SerializerBase.java:55)
Unknown.b1(SerializerBase.java:112)
Unknown.D$(AbstractSerializationStreamReader.java:119)
Unknown.uAc(CustomException_FieldSerializer.java:39)
Unknown.uBc(ServerSideException_FieldSerializer.java:12)
Unknown.f1(SerializerBase.java:46)
Unknown._0(SerializerBase.java:92)
Unknown.D$(AbstractSerializationStreamReader.java:119)
Unknown.B_(RequestCallbackAdapter.java:216)
Unknown._o(Request.java:287)

After using @Christian Kuetbach's answer, here is what I get now:

Unknown.com_google_gwt_core_client_impl_StackTraceCreator$CollectorEmulated_$fillInStackTrace__Lcom_google_gwt_core_client_impl_StackTraceCreator$CollectorEmulated_2Ljava_lang_Throwable_2V(StackTraceCreator.java:168) Unknown.java_lang_Throwable_Throwable__Ljava_lang_String_2Ljava_lang_Throwable_2V(StackTraceCreator.java:421) Unknown.com_google_gwt_user_client_rpc_StatusCodeException_StatusCodeException__ILjava_lang_String_2V(StatusCodeException.java:35) Unknown.com_google_gwt_user_client_rpc_impl_RequestCallbackAdapter_$onResponseReceived__Lcom_google_gwt_user_client_rpc_impl_RequestCallbackAdapter_2Lcom_google_gwt_http_client_Request_2Lcom_google_gwt_http_client_Response_2V(RequestCallbackAdapter.java:209) Unknown.com_google_gwt_http_client_Request_$fireOnResponseReceived__Lcom_google_gwt_http_client_Request_2Lcom_google_gwt_http_client_RequestCallback_2V(Request.java:287) Unknown.com_google_gwt_http_client_RequestBuilder$1_onReadyStateChange__Lcom_google_gwt_xhr_client_XMLHttpRequest_2V(RequestBuilder.java:395) Unknown.anonymous(XMLHttpRequest.java:287)

Please Help!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Why?

As Christian Kuetbach said, this is the difference between running in DevMode (where your code executes in Java) and prod mode (where your code has been compiled to JavaScript and optimized, which includes renaming classes and methods).

How do you fix this?

You don't. Generally speaking, showing stack traces to your users is not a good idea. Much better is to log the exception by sending it to the server (e.g. use java.util.logging to log, along with the SimpleRemoteLogHandler to send the log to the server, where it'll be logged using java.util.logging).

There are ways to deobfuscate the stack trace though, and the RemoteLoggingServiceImpl servlet can be configured to do it automatically.
See http://code.google.com/p/google-web-toolkit/wiki/WebModeExceptions for the gory details.

If you can't or don't want to use remote logging, then you can "manually" deobfuscate the stack trace: look at the file in WEB-INF/deploy (default location, can be changed by passing -deploy to the GWT compiler) corresponding with the permutation (same name as the *.cache.* file loaded by the browser), it'll tell you which Java method the Le method originates from.
But you already have the source file name and line number, so you don't really need it, right?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...