Java 从持久存储异常加载会话

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20622746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 03:10:56  来源:igfitidea点击:

exception loading sessions from persistent storage

javaspringspring-mvc

提问by CodeMed

I have made many changes to 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:

对 spring petclinic 应用程序进行了许多更改。目前,当我使用 eclipse run as...run on server 在 tomcat 服务器的新实例中启动应用程序时,我收到以下错误消息:

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 the petclinic code at githubto see the structure of the application, if that helps you see where I should look to find the problem. Here is the stack trace:

堆栈跟踪没有列出应用程序中的任何文件,所以我不知道在哪里查看应用程序代码来解决问题。您可以查看github的 petclinic 代码以查看应用程序的结构,如果这有助于您了解我应该在哪里查找问题。这是堆栈跟踪:

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'  

采纳答案by Will Keeling

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.

这是因为 Tomcat 无法加载先前关闭时保存的先前序列化的 Web 会话。这可能是因为 Tomcat 没有完全关闭,因此会话对象在序列化期间被损坏。

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.xmland setting the pathnameattribute of the <Manager>to an empty string. This is well documented in the file for Tomcat 7:

消除此错误的一种方法是禁用跨重新启动的会话持久性。您可以通过编辑文件CATALINA_HOME/conf/context.xml并将 的pathname属性设置为<Manager>空字符串来完成此操作。这在 Tomcat 7 的文件中有详细记录:

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

<Manager pathname="" />

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

您还应该在 Tomcat 关闭时session.serCATALINA_HOME/work/Catalina/localhost/<appName>文件夹中删除所有旧文件。

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.

如果需要跨重新启动的会话持久性,这在您的情况下可能是不可接受的。在这种情况下,需要进一步调试问题。

回答by agugar

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

我在 eclipse 中的一个项目中遇到了类似的错误。我通过以下步骤解决了它:

  • 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
  • 对项目进行清理
  • 在eclipse的server视图删除Tomcat服务器
  • 使用向导在eclipse的服务器视图定义一个新的Tomcat服务器
  • 将项目添加到新定义的Tomcat服务器

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

之后,运行这个新的 Tomcat 服务器一切正常。

回答by M.Nethaji

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

删除tomcat“工作”文件夹。重启tomcat服务器,希望现在它可以正常运行,没有任何异常或错误!

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

这可以通过在 Tomcat 中选择服务器并选择“清理 Tomcat 工作目录”来完成

enter image description here

在此处输入图片说明

回答by Krishna

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

这只是因为 Persist Class 没有正确序列化只是停止 Apache。删除项目并清理项目和服务器。

and Just Redeploy Here its Done. good luck.

并在此处重新部署就完成了。祝你好运。

回答by Manbumihu Manavan

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

只需清理 Tomcat 工作目录..这对我来说效果很好。

回答by user2664008

-The class should implement Serializable interface with serialVersionUID. - Do the clean build and restart the server

- 该类应该使用 serialVersionUID 实现 Serializable 接口。- 进行干净的构建并重新启动服务器