Tomcat java.io.NotSerializableException错误

时间:2012-09-24 09:12:00

标签: java tomcat

启动Tomcat 7时出现此错误:

 sept. 24, 2012 9:59:13 AM org.apache.catalina.session.StandardManager doLoad
    Grave: "IOException" lors du chargement de sessions persistantes: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel
    java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1964)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1888)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
        at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1595)
        at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:1060)
        at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:284)
        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:5293)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1595)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1585)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)
    Caused by: java.io.NotSerializableException: org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
        at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1671)
        at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1077)
        at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:432)
        at org.apache.catalina.session.StandardManager.unload(StandardManager.java:353)
        at org.apache.catalina.session.StandardManager.stopInternal(StandardManager.java:518)
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
        at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5473)
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
        at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1611)
        at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1600)
        ... 5 more

    sept. 24, 2012 9:59:13 AM org.apache.catalina.session.StandardManager startInternal
    Grave: Exception au chargement des sessions depuis le stockage persistant (persistent storage)
    java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1351)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1964)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1888)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1771)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)
        at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1595)
        at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:1060)
        at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:284)
        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:5293)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1595)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1585)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)
    Caused by: java.io.NotSerializableException: org.objectweb.salome_tmf.ihm.main.datawrapper.DataModel
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1528)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1493)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
        at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1671)
        at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1077)
        at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:432)
        at org.apache.catalina.session.StandardManager.unload(StandardManager.java:353)
        at org.apache.catalina.session.StandardManager.stopInternal(StandardManager.java:518)
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
        at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5473)
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
        at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1611)
        at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1600)
        ... 5 more

这是我的班级:

 public class DataModel implements ApiConstants, 

 DataConstants,IDataModelWrapper {     
  }

ApiConstants,DataConstants,IDataModelWrapper是简单的接口。 我应该实现Serializable interfae ??

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:4)

每当您向会话添加对象时,您应始终将其设为Serializable

它有两个目的:

  • 如果不经常访问,它允许容器将会话存储到磁盘
  • 它允许容器在同一群集的节点之间共享会话数据