我想使用GWT Remote Logging。這是我做過什麼:GWT遠程日誌記錄不能記錄Throwable Stacktrace?
在我的web.xml文件中我所做的:
<servlet>
<servlet-name>remoteLogging</servlet-name>
<servlet-class>com.google.gwt.logging.server.RemoteLoggingServiceImpl</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>remoteLogging</servlet-name>
<url-pattern>/web/remote_logging</url-pattern>
</servlet-mapping>
在我gwt.xml文件我所做的:
<module rename-to='web'>
...
<inherits name="com.google.gwt.logging.Logging" />
<set-property name="gwt.logging.logLevel" value="INFO" />
<set-property name="gwt.logging.enabled" value="TRUE" />
<set-property name="gwt.logging.popupHandler" value="DISABLED" />
<set-property name="gwt.logging.developmentModeHandler" value="ENABLED" />
<set-property name="gwt.logging.simpleRemoteHandler" value="ENABLED" />
在我的GWT Java代碼我
而且某處做:
Logger logger = Logger.getLogger("NameOfYourLogger");
logger.log(Level.SEVERE, "this message should get logged");
但是,當我嘗試登錄堆棧跟蹤(的Throwable)是這樣的:
// Throwable throwable
LogRecord lr = new LogRecord(Level.SEVERE, "test");
lr.setThrown(throwable);
logger.log(lr);
我得到一個錯誤:
16:24:26.887 [ERROR] [web] Sun Feb 09 16:24:26 CET 2014 WireActivityLogger
SEVERE: Remote logging failed:
com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException: java.lang.ClassCastException: com.google.gwt.core.client.impl.SerializableThrowable cannot be cast to com.google.gwt.core.shared.SerializableThrowable
at com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException_FieldSerializer.instantiate(IncompatibleRemoteServiceException_FieldSerializer.java:16)
at com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException_FieldSerializer.create(IncompatibleRemoteServiceException_FieldSerializer.java:25)
at com.google.gwt.user.client.rpc.impl.SerializerBase.instantiate(SerializerBase.java:115)
at com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader.deserialize(ClientSerializationStreamReader.java:396)
at com.google.gwt.user.client.rpc.impl.AbstractSerializationStreamReader.readObject(AbstractSerializationStreamReader.java:119)
at com.google.gwt.user.client.rpc.impl.RequestCallbackAdapter.onResponseReceived(RequestCallbackAdapter.java:216)
at com.google.gwt.http.client.Request.fireOnResponseReceived(Request.java:258)
at com.google.gwt.http.client.RequestBuilder$1.onReadyStateChange(RequestBuilder.java:412)
at sun.reflect.GeneratedMethodAccessor103.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForReturn(BrowserChannelServer.java:338)
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:219)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:571)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:279)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:242)
at sun.reflect.GeneratedMethodAccessor101.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:293)
at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:547)
at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
at java.lang.Thread.run(Thread.java:722)
我怎麼能遠程日誌堆棧跟蹤?
編輯:我也試着
// Throwable throwable
LogRecord lr = new LogRecord(Level.SEVERE, throwable.toString());
logger.log(lr);
和
// Throwable throwable
LogRecord lr = new LogRecord(Level.SEVERE, throwable.getMessage());
logger.log(lr);
,但我得到了以下錯誤:
| Error 2014-02-19 02:21:04,017 [http-nio-8080-exec-7] ERROR [localhost].[/test] - Exception while dispatching incoming RPC call
Message: Service method 'public abstract java.lang.String com.google.gwt.logging.shared.RemoteLoggingService.logOnServer(java.util.logging.LogRecord)' threw an unexpected exception: java.lang.NullPointerException
Line | Method
->> 389 | encodeResponseForFailure in com.google.gwt.user.server.rpc.RPC
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 579 | invokeAndEncodeResponse in ''
| 265 | processCall . . . . . . in com.google.gwt.user.server.rpc.RemoteServiceServlet
| 305 | processPost in ''
| 62 | doPost . . . . . . . . . in com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
| 46 | doFilterInternal in org.grails.jaxrs.web.JaxrsFilter
| 70 | doFilter . . . . . . . . in com.github.greengerong.PreRenderSEOFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
Caused by NullPointerException: null
->> 262 | hash in java.util.Hashtable
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 459 | get in ''
| 489 | findLogger . . . . . . . in java.util.logging.LogManager$LoggerContext
| 910 | getLogger in java.util.logging.LogManager
| 400 | demandLogger . . . . . . in ''
| 317 | demandLogger in java.util.logging.Logger
| 361 | getLogger . . . . . . . in ''
| 62 | logOnServer in com.google.gwt.logging.server.RemoteLoggingServiceUtil
| 46 | logOnServer . . . . . . in com.google.gwt.logging.server.RemoteLoggingServiceImpl
| 561 | invokeAndEncodeResponse in com.google.gwt.user.server.rpc.RPC
| 265 | processCall . . . . . . in com.google.gwt.user.server.rpc.RemoteServiceServlet
| 305 | processPost in ''
| 62 | doPost . . . . . . . . . in com.google.gwt.user.server.rpc.AbstractRemoteServiceServlet
| 46 | doFilterInternal in org.grails.jaxrs.web.JaxrsFilter
| 70 | doFilter . . . . . . . . in com.github.greengerong.PreRenderSEOFilter
| 1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
| 615 | run . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run in java.lang.Thread
編輯:
這是我的代碼一世使用方法:
import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
new AsyncCallback<GetResults<ItemDto>>() {
@Override
public void onFailure(Throwable e) {
Logger logger = Logger.getLogger("test");
logger.log(Level.SEVERE, "this message should get logged");
LogRecord lr = new LogRecord(Level.SEVERE, e.toString());
logger.log(lr);
}
...
}
'InvocationException:'然後呢?你的模塊的名稱是什麼(根據你的web.xml應該是'web')?你的服務器日誌中的任何輸出? –
@ColinAlworth我更新了我的問題記錄作品的字符串,但不是Throwable,正如我指出的那樣。任何想法? – confile