我正在使用GWT。我有以下代码来显示客户端异常详细信息。
public void onModuleLoad() {
GWT.setUncaughtExceptionHandler(new
GWT.UncaughtExceptionHandler() {
public void onUncaughtException(Throwable e) {
// my logic which will display error details
}
在托管模式下,每件事都可以正常工作。我在托管模式下获得了明确的异常堆栈跟踪详细信息,如下所示:
Error: java.lang.NullPointerException
com.sample.UserDetailsGrid$1.handleEvent(UserDetailsGrid.java:52)
com.sample.UserDetailsGrid$1.handleEvent(UserDetailsGrid.java:1)
com.extjs.gxt.ui.client.event.BaseObservable.callListener(BaseObservable.java:178)
com.extjs.gxt.ui.client.event.BaseObservable.fireEvent(BaseObservable.java:86)
com.extjs.gxt.ui.client.widget.Component.fireEvent(Component.java:456)
com.extjs.gxt.ui.client.widget.grid.Grid.onClick(Grid.java:813)
com.extjs.gxt.ui.client.widget.grid.Grid.onComponentEvent(Grid.java:496)
com.extjs.gxt.ui.client.widget.Component.onBrowserEvent(Component.java:884)
com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1308)
com.google.gwt.user.client.DOM.dispatchEvent(DOM.java:1264)
sun.reflect.GeneratedMethodAccessor49.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
但问题是,一旦将java文件编译成javascript并部署到tomcat,我会得到如下的异常细节,我们无法从堆栈跟踪中理解任何内容。:
Error: (TypeError): null has no properties stack: FLg([object Object],[object Object])@http://localhost:9999/mywebapp/21D01FA6800CA5B30FF5BE80916CCD06.cache.html:
Unknown.FLg(Unknown source:0)
Unknown.ILg(Unknown source:0)
Unknown._Xb(Unknown source:0)
Unknown.Rkc(Unknown source:0)
Unknown.bqd(Unknown source:0)
Unknown.wqd(Unknown source:0)
Unknown.ilc(Unknown source:0)
Unknown.tmc(Unknown source:0)
Unknown.I5f(Unknown source:0)
Unknown.anonymous(Unknown source:0)
Unknown.VNd(Unknown source:0)
你能解释一下这种行为的原因吗?
谢谢!
答案 0 :(得分:1)
在开发模式下,您的代码以Java格式运行。在prod模式下,编译的JavaScript被混淆。
请参阅https://code.google.com/p/google-web-toolkit/wiki/WebModeExceptions了解反混淆堆栈跟踪(在服务器端)