JSF 托管 bean 在 Tomcat 部署期间导致 java.io.NotSerializableException

Posted

技术标签:

【中文标题】JSF 托管 bean 在 Tomcat 部署期间导致 java.io.NotSerializableException【英文标题】:JSF managed bean causing java.io.NotSerializableException during Tomcat deployment 【发布时间】:2011-06-17 11:19:36 【问题描述】:

在 Tomcat 7 上部署我的 webApplication 时,我得到了下面的控制台输出。重新启动服务器两次或三次后,它可以正常工作。

我正在使用 JSF、Tomcat 和一个与业务逻辑部分的 RMI 连接(在这里应该没关系?)

@EJB in @ViewScoped managed bean causes java.io.NotSerializableException - 在这里我读到了序列化。但在那种情况下,客户端状态保存被激活,而我的 webApp 中却不是这种情况(据我的 web.xml 告诉我)。那么我的 viewscoped ManagedBeans 的序列化是必要的还是有另一个失败?

这是我的启动控制台输出(对不起,其中的德语部分):

28.01.2011 20:25:05 org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Programme\Java\jdk1.6.0_21\jre\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Programme/Java/jre6/bin/client;C:/Programme/Java/jre6/bin;C:/Programme/Java/jre6/lib/i386;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\Gemeinsame Dateien\Lenovo;C:\Programme\ATI Technologies\ATI.ACE\Core-Static;C:\Programme\Java\jdk1.6.0_20;C:\StudiPortal\TortoiseSVN\bin;C:\StudiPortal\apache-maven-2.0.11\bin;C:\Programme\Intel\WiFi\bin\;C:\Programme\ThinkPad\ConnectUtilities;C:\Programme\GTK2-Runtime\bin;C:\Programme\Open***\bin
28.01.2011 20:25:05 org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNUNG: [SetPropertiesRule]Server/Service/Engine/Host/Context Setting property 'source' to 'org.eclipse.jst.jee.server:shapeyourbody' did not find a matching property.
28.01.2011 20:25:06 org.apache.coyote.http11.Http11Protocol init
INFO: Initializing Coyote HTTP/1.1 on http-8080
28.01.2011 20:25:06 org.apache.coyote.ajp.AjpProtocol init
INFO: Initializing Coyote AJP/1.3 on ajp-8009
28.01.2011 20:25:06 org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 481 ms
28.01.2011 20:25:06 org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
28.01.2011 20:25:06 org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.5
28.01.2011 20:25:09 com.sun.faces.config.ConfigureListener contextInitialized
INFO: Mojarra 2.0.3 (FCS b03) für Kontext '/shapeyourbody' wird initialisiert.
28.01.2011 20:25:10 com.sun.faces.spi.InjectionProviderFactory createInstance
INFO: JSF1048: PostConstruct/PreDestroy-Annotationen vorhanden.  Verwaltete Bean-Methoden, die mit diesen Annotationen markiert sind, lassen die entsprechenden Annotationen verarbeiten.
28.01.2011 20:25:10 com.sun.faces.config.processor.FaceletTaglibConfigProcessor processComponent
WARNUNG: JSF1029:  Die Anwendung hat Version 2.0 (entweder ausdrücklich durch die Version von /WEB-INF/faces-config.xml oder eine fehlende /WEB-INF/faces-confg.xml), jedoch hängt Klasse 'org.apache.myfaces.custom.aliasbean.AliasBeanTagHandler' von einer Legacy-Facelet-Klasse ab.  Das von dieser Klasse registrierte Facelet-Artefakt wird nicht registriert.
28.01.2011 20:25:10 com.sun.faces.config.processor.FaceletTaglibConfigProcessor processComponent
WARNUNG: JSF1029:  Die Anwendung hat Version 2.0 (entweder ausdrücklich durch die Version von /WEB-INF/faces-config.xml oder eine fehlende /WEB-INF/faces-confg.xml), jedoch hängt Klasse 'org.apache.myfaces.custom.aliasbean.AliasBeansScopeTagHandler' von einer Legacy-Facelet-Klasse ab.  Das von dieser Klasse registrierte Facelet-Artefakt wird nicht registriert.
28.01.2011 20:25:10 com.sun.faces.config.processor.FaceletTaglibConfigProcessor processComponent
WARNUNG: JSF1029:  Die Anwendung hat Version 2.0 (entweder ausdrücklich durch die Version von /WEB-INF/faces-config.xml oder eine fehlende /WEB-INF/faces-confg.xml), jedoch hängt Klasse 'org.apache.myfaces.custom.calendar.htmlInputCalendarTagHandler' von einer Legacy-Facelet-Klasse ab.  Das von dieser Klasse registrierte Facelet-Artefakt wird nicht registriert.
28.01.2011 20:25:10 com.sun.faces.config.processor.FaceletTaglibConfigProcessor processComponent
WARNUNG: JSF1029:  Die Anwendung hat Version 2.0 (entweder ausdrücklich durch die Version von /WEB-INF/faces-config.xml oder eine fehlende /WEB-INF/faces-confg.xml), jedoch hängt Klasse 'org.apache.myfaces.custom.date.HtmlInputDateTagHandler' von einer Legacy-Facelet-Klasse ab.  Das von dieser Klasse registrierte Facelet-Artefakt wird nicht registriert.
28.01.2011 20:25:10 com.sun.faces.config.processor.FaceletTaglibConfigProcessor processComponent
WARNUNG: JSF1029:  Die Anwendung hat Version 2.0 (entweder ausdrücklich durch die Version von /WEB-INF/faces-config.xml oder eine fehlende /WEB-INF/faces-confg.xml), jedoch hängt Klasse 'org.apache.myfaces.custom.schedule.ScheduleTagHandler' von einer Legacy-Facelet-Klasse ab.  Das von dieser Klasse registrierte Facelet-Artefakt wird nicht registriert.
28.01.2011 20:25:10 com.sun.faces.config.processor.FaceletTaglibConfigProcessor processComponent
WARNUNG: JSF1029:  Die Anwendung hat Version 2.0 (entweder ausdrücklich durch die Version von /WEB-INF/faces-config.xml oder eine fehlende /WEB-INF/faces-confg.xml), jedoch hängt Klasse 'org.apache.myfaces.custom.tabbedpane.HtmlPanelTabbedPaneTagHandler' von einer Legacy-Facelet-Klasse ab.  Das von dieser Klasse registrierte Facelet-Artefakt wird nicht registriert.
28.01.2011 20:25:10 com.sun.faces.config.processor.FaceletTaglibConfigProcessor processComponent
WARNUNG: JSF1029:  Die Anwendung hat Version 2.0 (entweder ausdrücklich durch die Version von /WEB-INF/faces-config.xml oder eine fehlende /WEB-INF/faces-confg.xml), jedoch hängt Klasse 'org.apache.myfaces.custom.tree.taglib.TreeTagHandler' von einer Legacy-Facelet-Klasse ab.  Das von dieser Klasse registrierte Facelet-Artefakt wird nicht registriert.
28.01.2011 20:25:10 com.sun.faces.config.processor.FaceletTaglibConfigProcessor processHandlerClass
WARNUNG: JSF1029:  Die Anwendung hat Version 2.0 (entweder ausdrücklich durch die Version von /WEB-INF/faces-config.xml oder eine fehlende /WEB-INF/faces-confg.xml), jedoch hängt Klasse '[handler-class: null]' von einer Legacy-Facelet-Klasse ab.  Das von dieser Klasse registrierte Facelet-Artefakt wird nicht registriert.
28.01.2011 20:25:10 com.sun.faces.config.processor.FaceletTaglibConfigProcessor processHandlerClass
WARNUNG: JSF1029:  Die Anwendung hat Version 2.0 (entweder ausdrücklich durch die Version von /WEB-INF/faces-config.xml oder eine fehlende /WEB-INF/faces-confg.xml), jedoch hängt Klasse '[handler-class: null]' von einer Legacy-Facelet-Klasse ab.  Das von dieser Klasse registrierte Facelet-Artefakt wird nicht registriert.
28.01.2011 20:25:10 com.sun.faces.config.processor.FaceletTaglibConfigProcessor processHandlerClass
WARNUNG: JSF1029:  Die Anwendung hat Version 2.0 (entweder ausdrücklich durch die Version von /WEB-INF/faces-config.xml oder eine fehlende /WEB-INF/faces-confg.xml), jedoch hängt Klasse '[handler-class: null]' von einer Legacy-Facelet-Klasse ab.  Das von dieser Klasse registrierte Facelet-Artefakt wird nicht registriert.
28.01.2011 20:25:10 com.sun.faces.config.processor.FaceletTaglibConfigProcessor processHandlerClass
WARNUNG: JSF1029:  Die Anwendung hat Version 2.0 (entweder ausdrücklich durch die Version von /WEB-INF/faces-config.xml oder eine fehlende /WEB-INF/faces-confg.xml), jedoch hängt Klasse '[handler-class: null]' von einer Legacy-Facelet-Klasse ab.  Das von dieser Klasse registrierte Facelet-Artefakt wird nicht registriert.
28.01.2011 20:25:10 org.apache.catalina.session.StandardManager doLoad
SCHWERWIEGEND: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.dhbw.stg.wwi2008c.mopro.ui.viewscoped.MachineReservationListBean
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.dhbw.stg.wwi2008c.mopro.ui.viewscoped.MachineReservationListBean
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.util.HashMap.readObject(HashMap.java:1030)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.util.HashMap.readObject(HashMap.java:1030)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.util.HashMap.readObject(HashMap.java:1030)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.util.HashMap.readObject(HashMap.java:1030)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1576)
    at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:1059)
    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:465)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5025)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1035)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:738)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1035)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:289)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:442)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:674)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:596)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
Caused by: java.io.NotSerializableException: org.dhbw.stg.wwi2008c.mopro.ui.viewscoped.MachineReservationListBean
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at java.util.HashMap.writeObject(HashMap.java:1001)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at java.util.HashMap.writeObject(HashMap.java:1001)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at java.util.HashMap.writeObject(HashMap.java:1001)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at java.util.HashMap.writeObject(HashMap.java:1001)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1652)
    at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1076)
    at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:406)
    at org.apache.catalina.session.StandardManager.unload(StandardManager.java:353)
    at org.apache.catalina.session.StandardManager.stopInternal(StandardManager.java:492)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:216)
    at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5195)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:216)
    at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1074)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:216)
    at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1074)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:216)
    at org.apache.catalina.core.StandardService.stopInternal(StandardService.java:498)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:216)
    at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:695)
    at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:216)
    at org.apache.catalina.startup.Catalina.stop(Catalina.java:663)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:630)
    ... 6 more
28.01.2011 20:25:10 org.apache.catalina.session.StandardManager startInternal
SCHWERWIEGEND: Exception loading sessions from persistent storage
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.dhbw.stg.wwi2008c.mopro.ui.viewscoped.MachineReservationListBean
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.util.HashMap.readObject(HashMap.java:1030)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.util.HashMap.readObject(HashMap.java:1030)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readArray(ObjectInputStream.java:1667)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1323)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.util.HashMap.readObject(HashMap.java:1030)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at java.util.HashMap.readObject(HashMap.java:1030)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
    at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
    at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
    at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
    at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
    at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1576)
    at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:1059)
    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:465)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5025)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1035)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:738)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1035)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:289)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:442)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:674)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:596)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
Caused by: java.io.NotSerializableException: org.dhbw.stg.wwi2008c.mopro.ui.viewscoped.MachineReservationListBean
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at java.util.HashMap.writeObject(HashMap.java:1001)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at java.util.HashMap.writeObject(HashMap.java:1001)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945)
    at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
    at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
    at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1338)
    at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1146)
    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
    at java.util.HashMap.writeObject(HashMap.java:1001)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    ... 6 more
28.01.2011 20:25:11 org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-8080
28.01.2011 20:25:11 org.apache.coyote.ajp.AjpProtocol start
INFO: Starting Coyote AJP/1.3 on ajp-8009
28.01.2011 20:25:11 org.apache.catalina.startup.Catalina start
INFO: Server startup in 4976 ms

感谢您的帮助

【问题讨论】:

【参考方案1】:

这是跟踪的相关位:

SCHWERWIEGEND: Exception loading sessions from persistent storage
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.dhbw.stg.wwi2008c.mopro.ui.viewscoped.MachineReservationListBean
     ...
     at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1576)
     at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:1059)
     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:465)
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:140)
     ...

这个问题与您链接的问题不同。默认情况下,当 Tomcat 关闭时,它会将HttpSession 序列化到磁盘,然后在启动时从磁盘重新加载,以便最终用户可以继续浏览器会话而不会丢失任何会话数据。

在这种情况下,任何会话属性都应该实现Serializable。 JSF 视图状态默认存储在会话中,包括所有适当的视图范围 bean。他们还需要实现 Serializable 才能在 Tomcat 关闭/重启后存活下来。

从技术上讲,您可以忽略它。无论如何,JSF 将重新创建会话/视图范围的 bean,当它还不存在时。但是,最终用户将无法继续使用相同的会话/视图范围数据。当会话不包含任何不可序列化的对象时,不会发生这些异常。这就是它“有时”起作用的原因。

如果您想完全禁用会话持久性以便您不会被这些异常/警告所困扰,那么您需要添加一个带有 empty 的 <Manager> 元素strong> pathname 属性到相关 webapp 的 <Context> 元素。

<Context ... >
    <Manager pathname="" />
</Context>

这基本上指示 Tomcat 使用 no 会话管理器。

另见:

Tomcat 7.0 Configuration Reference - The Context container java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException

【讨论】:

所以这没什么大不了的 :-) 谢谢你 bauke :-) 我必须在星期一提交我的大学作业,而且我有很多错误 -.- 修复错误就是其中的一部分糟糕的软件工程。但如果没有大多数程序员,我认为不会有工作;-) @BalusC:我有一个这个答案的截图,它有点旧,因此它不包括编辑的部分。句子 The JSF UIViewRoot is in essence stored in the session 被删除是因为 UIViewRoot 没有实现 Serializable 还是您想到了其他一些事情? @Shirgill:我用错词来指代 JSF 视图状态。 @BalusC:谢谢。 bean 是否也存储在视图状态中? @Shirgill:视图范围的 bean 与视图状态一起存储在会话中,但不在视图状态中。 IE。当状态保存方法为客户端时,视图状态存储在 HTML 中的隐藏输入字段中,但视图范围的 bean 仍存储在 HTTP 会话中。

以上是关于JSF 托管 bean 在 Tomcat 部署期间导致 java.io.NotSerializableException的主要内容,如果未能解决你的问题,请参考以下文章

GlassFish 域中的 JSF 托管 Bean 唯一性

基于 JSF 表单的身份验证 + 托管 Bean 登录不起作用

Bean Validation @NotNull、@NotBlank 和 @NotEmpty 在 JSF+Tomcat 中不起作用

迁移到 tomcat 后,将枚举值作为参数从 JSF 页面传递给 bean 方法失败

将 JSF 托管 bean 迁移到 CDI 托管 bean

Spring JSF 集成:如何在 JSF 托管 bean 中注入 Spring 组件/服务?