Itzik Yatom
Itzik Yatom

Reputation: 165

Finding the Java actual stack trace from a javascript stack trace

We have implemented a general mechanism that logs on the server exceptions from the GWT client side. Naturally, some of them are unexpected exceptions (such as NPE), and therefore we are getting kind of these stack traces in our log (an excerpt):

java.lang.Throwable: One or more exceptions caught, see full set in UmbrellaException#getCauses
        at Unknown.Hq(Unknown Source)
        at Unknown.ihb(Unknown Source)
        at Unknown.anonymous(Unknown Source)
        at Unknown.anonymous(Unknown Source)
        at Unknown.anonymous(Unknown Source)
Caused by: java.lang.Throwable: (TypeError): d is null
stack: EG([object Object],[object Object])@http://domain/path/0B15791BA99231E6B88EAF3BDE38EB64.cache.html:3282

fileName: http://domain/path/0B15791BA99231E6B88EAF3BDE38EB64.cache.html
lineNumber: 3282
        at Unknown.EG(Unknown Source)
        at Unknown.DG(Unknown Source)

How can I find the class and line number in the original java source?

I don't want to deploy a detailed compiled version, since I don't have information about the exact scenario and I can't reproduce the exception.

Upvotes: 6

Views: 3648

Answers (1)

Thomas Broyer
Thomas Broyer

Reputation: 64541

The GWT compiler outputs the mapping in symbolMap files in the -deploy and -extra locations (where -deploy defaults to the -war's WEB-INF/deploy, and -extra is not emitted by default).
I use it manually to debug weird things from time to time.

You can also deobfuscate traces programmatically, using the StackTraceDeobfuscator.
FYI, this class is used by the RemoteLoggingServiceImpl GWT-RPC servlet and the Logging RequestFactory service; respectively called by the SimpleRemoteLogHandler and RequestFactoryLogHandler (they're java.util.logging.LogHandlers which you can use with the logging API that GWT supports). In this case, it looks into the WEB-INF/deploy of the webapp (which is why -deploy defaults there).

Upvotes: 6

Related Questions