java.io.EOFException

Posted O_wen 快到碗里来

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java.io.EOFException相关的知识,希望对你有一定的参考价值。

 

错误代码如下:

严重: IOException while loading persisted sessions: java.io.EOFException  
java.io.EOFException  
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2325)  
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2794)  
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:801)  
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299)  
    at org.apache.catalina.util.CustomObjectInputStream.<init>(CustomObjectInputStream.java:58)  
    at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:226)  
    at org.apache.catalina.session.StandardManager.load(StandardManager.java:183)  
    at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:473)  
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)  
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5293)  
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)  
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)  
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)  
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698)  
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1119)  
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1760)  
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)  
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)  
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
    at java.lang.Thread.run(Thread.java:744)  
一月 02, 2014 2:38:27 下午 org.apache.catalina.session.StandardManager startInternal  
严重: Exception loading sessions from persistent storage  
java.io.EOFException  
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2325)  
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2794)  
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:801)  
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:299)  
    at org.apache.catalina.util.CustomObjectInputStream.<init>(CustomObjectInputStream.java:58)  
    at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:226)  
    at org.apache.catalina.session.StandardManager.load(StandardManager.java:183)  
    at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:473)  
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)  
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5293)  
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)  
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:726)  
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:702)  
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:698)  
    at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1119)  
    at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1760)  
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)  
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)  
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
    at java.lang.Thread.run(Thread.java:744)  
一月 02, 2014 2:38:27 下午 org.apache.catalina.startup.HostConfig deployDirectory

 

错误的原因是:EOFException表示输入过程中意外地到达文件尾或流尾的信号,导致从session中获取数据失败。这是由于tomcat上次非正常关闭时有一些活动session被持久化(表现为一些临时文件),在重启时,tomcat尝试去恢复这些session的持久化数据但又读取失败造成的。此异常不影响系统的使用。

 

技术分享

可以看到,我正在使用的day56项目中多了一个sessions.ser文件,把此文件删除即可tomcat即可正常的使用.

 

如果你的项目中不知道是哪个项目引起的.就把Catalina目录下的所有文件删除,即可.

以上是关于java.io.EOFException的主要内容,如果未能解决你的问题,请参考以下文章

Java Scoket之java.io.EOFException解决方案

Java Scoket之java.io.EOFException解决方案

java.io.EOFException

web编程 java.io.EOFException错误

java.io.EOFException java.io.ObjectInputStream$PeekInputStream.readFully 错误

java.io.EOFException