2018-10-31 17:24:04
[WARN]-[Thread: qtp984213526-14]-[org.eclipse.jetty.server.session.SessionHandler.complete()]:
org.eclipse.jetty.server.session.UnwriteableSessionDataException: Unwriteable session node0xyx88gn7c20ootfof94vyqf50 for node0__0.0.0.0
at org.eclipse.jetty.server.session.FileSessionDataStore.doStore(FileSessionDataStore.java:376)
at org.eclipse.jetty.server.session.AbstractSessionDataStore.store(AbstractSessionDataStore.java:103)
at org.eclipse.jetty.server.session.AbstractSessionCache.put(AbstractSessionCache.java:537)
at org.eclipse.jetty.server.session.SessionHandler.complete(SessionHandler.java:371)
at org.eclipse.jetty.server.session.SessionHandler.complete(SessionHandler.java:388)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1577)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1242)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:503)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.NotSerializableException: java.lang.ThreadLocal
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1184)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1548)
at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1509)
at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1432)
at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1178)
at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:348)
at org.eclipse.jetty.server.session.FileSessionDataStore.save(FileSessionDataStore.java:537)
at org.eclipse.jetty.server.session.FileSessionDataStore.doStore(FileSessionDataStore.java:369)
... 23 more
每次发起请求就会出现这个异常 但是不影响使用 是应该序列化 没有序列化吗
看一下 JettyServer.java 源码的 void persistSession(Server server) 方法,是用来在重启项目时先保存 session 到文件之中,便于在开发类似登录功能时免除反复的登录,提升开发体验
解决办法是找到那个被保存在 session 中,而不能被持久化的对象,不要将它放在 session 之中,注意这个对象可能深藏在对象的对象的对象之中,所以要根据异常提示细心追踪
还有一个办法是继承一下 JettyServer,在报异常的地方用一个 try catch ,不让它抛出异常