Why is Tomcat unable to show the actual stack trace?

后端 未结 3 1788
迷失自我
迷失自我 2020-12-18 09:36

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

3条回答
  •  鱼传尺愫
    2020-12-18 09:58

    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?

提交回复
热议问题