23 May 2011

How to solve problem with IOException while loading persisted sessions: java.io.EOFException in Eclipce with Tomcat

Solution for Eclipse 3.6 ,Tomcat 6.0.29

If you see error
"IOException while loading persisted sessions: java.io.EOFException"

which looks very similar to:
org.apache.catalina.session.StandardManager doLoad
SEVERE: IOException while loading persisted sessions: java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2281)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2750)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:780)
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:280)

then it means that your session file was corrupted (It happens if tomcat terminated abnormally ).
What you need to do  ?

if you using Eclipse,then ....
1)Open Server tab
2)Choose your Tomcat server that is mood like British weather
3)Press right click on this server and press "Clean Tomcat Work Directory..." (btw. i am wondering why they add ... to name of this command )
4)Problem solved.

If you doesn't use Eclipse,then you need find file session.ser (btw. ser in Polish means cheese )  stored in 
somewhere in Catalina folder for example:
if you project is called awsomeproject then path will looks similar to   \work\Catalina\localhost\awsomeproject
in eclipse it will be
org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\ awsomeproject

but it depends how you define path  ${catalina.home}