exception loading sessions from persistent storage

JavaSpringSpring Mvc

Java Problem Overview


I have made many changes to https://github.com/spring-projects/spring-petclinic/">the spring petclinic application. At the moment, I am getting the following error message when I launch the application in a new instance of tomcat server using eclipse run as...run on server:

SEVERE: Exception loading sessions from persistent storage  

The server and application then subsequently are able to launch successfully, but I would like to fix whatever is causing the error message. Can anyone show me how to get past this error message?

The stack trace does not list any file from the application, so I don't know where to look in the application code to fix the problem. You can look in https://github.com/spring-projects/spring-petclinic/">the petclinic code at github to see the structure of the application, if that helps you see where I should look to find the problem. Here is the stack trace:

INFO  EhCacheManagerFactoryBean - Initializing EhCache CacheManager
INFO  ContextLoader - Root WebApplicationContext: initialization completed in 4376 ms
Dec 16, 2013 2:51:56 PM org.apache.catalina.session.StandardManager doLoad
SEVERE: IOException while loading persisted sessions: java.io.EOFException  
java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2280)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2749)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:779)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)
    at org.apache.catalina.util.CustomObjectInputStream.<init>(CustomObjectInputStream.java:58)
    at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:246)
    at org.apache.catalina.session.StandardManager.load(StandardManager.java:204)
    at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:491)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5443)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Dec 16, 2013 2:51:56 PM org.apache.catalina.session.StandardManager startInternal
SEVERE: Exception loading sessions from persistent storage  
java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2280)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2749)
    at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:779)
    at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)
    at org.apache.catalina.util.CustomObjectInputStream.<init>(CustomObjectInputStream.java:58)
    at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:246)
    at org.apache.catalina.session.StandardManager.load(StandardManager.java:204)
    at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:491)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5443)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Dec 16, 2013 2:51:56 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'petclinic'  

Java Solutions


Solution 1 - Java

This is to do with Tomcat not being able to load previously serialized web sessions that had been saved on an earlier shutdown. This may be because Tomcat didn't shutdown cleanly and so session objects got corrupted during serialization.

One way to make this error go away would be to disable session persistence across restarts. You can do this by editing the file CATALINA_HOME/conf/context.xml and setting the pathname attribute of the <Manager> to an empty string. This is well documented in the file for Tomcat 7:

<!-- Uncomment this to disable session persistence across Tomcat restarts -->

<Manager pathname="" />

You should also delete any old session.ser files from the CATALINA_HOME/work/Catalina/localhost/<appName> folder whilst Tomcat is shutdown.

This may not be acceptable in your case if session persistence across restarts is needed. In which case further debugging of the issue would be necessary.

Solution 2 - Java

Delete tomcat "work" folder. Restart tomcat server, hopefully now it'll run without any exception or error!

This can be done by selecting the server within Tomcat and selecting "Clean Tomcat Work Directory"

enter image description here

Solution 3 - Java

If you are working with Spring Boot, just add it to the application.properties:

server.servlet.session.persistent=false

Solution 4 - Java

Just Clean the Tomcat Work Directory..which is worked well to me.

Solution 5 - Java

It is Simply just Because Persist Class was not Serialize Properly just Stop Apache. Remove Project and Clean Project and Server as well.

and Just Redeploy Here its Done. good luck.

Solution 6 - Java

I had a similar error with a project in eclipse. I solved it with these steps:

  • Make a clean to the project
  • Delete the Tomcat server at the server view of eclipse
  • Define a new Tomcat server at the server view of eclipse using the wizard
  • Add the project to the newly defined Tomcat server

After that, running this new Tomcat server all worked perfectly.

Solution 7 - Java

-The class should implement Serializable interface with serialVersionUID.

  • Do the clean build and restart the server

Solution 8 - Java

In Spring boot you @ResponseBody annotation on your @GetMapping endpoint.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCodeMedView Question on Stackoverflow
Solution 1 - JavaWill KeelingView Answer on Stackoverflow
Solution 2 - JavaM.NethajiView Answer on Stackoverflow
Solution 3 - JavaPipiluçoView Answer on Stackoverflow
Solution 4 - JavaManbumihu ManavanView Answer on Stackoverflow
Solution 5 - JavaKishan BheemajiyaniView Answer on Stackoverflow
Solution 6 - JavaagugarView Answer on Stackoverflow
Solution 7 - Javauser2664008View Answer on Stackoverflow
Solution 8 - JavaRamin ArView Answer on Stackoverflow