Uploaded image for project: 'MyFaces CODI'
  1. MyFaces CODI
  2. EXTCDI-118

Could not serialize state: org.jboss.weld.bean.ManagedBean

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Won't Fix
    • Affects Version/s: 0.9.1, 0.9.2
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      JbossAS6Final, MyFaces2,
      jdk1.6_21, win7 64bit

      Description

      Having MyFaces configured now.

      Getting following error:
      09:58:21,068 INFO [org.apache.myfaces.util.ExternalSpecifications] MyFaces Unified EL support enabled
      09:58:21,209 INFO [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/myfaces-cdi-1.0.2-SNAPSHOT]] No state saving method defined, assuming default server state saving
      09:58:28,820 SCHWERWIEGEND [org.apache.myfaces.view.facelets.DefaultFaceletsStateManagementHelper] Exiting serializeView - Could not serialize state: org.jboss.weld.bean.ManagedBean: java.io.NotSerializableException: org.jboss.weld.bean.ManagedBean
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156) [:1.6.0_21]
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326) [:1.6.0_21]
      at java.util.concurrent.ConcurrentHashMap.writeObject(ConcurrentHashMap.java:1246) [:1.6.0_21]

      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) [:1.6.0_21]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) [:1.6.0_21]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) [:1.6.0_21]
      at java.lang.reflect.Method.invoke(Method.java:597) [:1.6.0_21]
      at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945) [:1.6.0_21]
      at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461) [:1.6.0_21]
      at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392) [:1.6.0_21]
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150) [:1.6.0_21]
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326) [:1.6.0_21]
      at java.util.HashMap.writeObject(HashMap.java:1001) [:1.6.0_21]
      at sun.reflect.GeneratedMethodAccessor270.invoke(Unknown Source) [:1.6.0_21]

        Activity

        Hide
        michaelschuetz Michael Schuetz added a comment -

        extract from weld-dev mailing list:
        Pete Muir:
        "Weird, I wonder what is trying to serialize a bean object, there is no spec requirement for these to be serializable. Can you find out?"

        ##

        Mark Struberg:
        "Hmm Beans are serialized all the day if you use a @ViewScoped context because the JSF ViewMap gets serialized/deserialized on every request. And the ViewScopeContext stores all the beans (+contextual instances, dependent objects, etc) in the ViewMap. I remember that this used to work in an earlier Weld version."

        ##

        Pete Muir:
        "Ok, so it sounds like a poor assumption by CODI that the Bean object is serializable. Michael, I suggest you file an issue in their issue tracker for this.
        Basically the issue is that the spec doesn't place any mandate on a PassivationCapable bean being serializable when passed to a Context impl. This is something we should definitely change in the spec (see CDI-24) as it's quite simple for the container to do for you, and something we can do in Weld for 1.2.0 (see WELD-793) but for CODI to be "spec compliant" for CDI 1.0 it does need to remove this assumption.
        NB OWB already does this hence why it works there."

        Show
        michaelschuetz Michael Schuetz added a comment - extract from weld-dev mailing list: Pete Muir: "Weird, I wonder what is trying to serialize a bean object, there is no spec requirement for these to be serializable. Can you find out?" ## Mark Struberg: "Hmm Beans are serialized all the day if you use a @ViewScoped context because the JSF ViewMap gets serialized/deserialized on every request. And the ViewScopeContext stores all the beans (+contextual instances, dependent objects, etc) in the ViewMap. I remember that this used to work in an earlier Weld version." ## Pete Muir: "Ok, so it sounds like a poor assumption by CODI that the Bean object is serializable. Michael, I suggest you file an issue in their issue tracker for this. Basically the issue is that the spec doesn't place any mandate on a PassivationCapable bean being serializable when passed to a Context impl. This is something we should definitely change in the spec (see CDI-24) as it's quite simple for the container to do for you, and something we can do in Weld for 1.2.0 (see WELD-793) but for CODI to be "spec compliant" for CDI 1.0 it does need to remove this assumption. NB OWB already does this hence why it works there."
        Hide
        gpetracek Gerhard Petracek added a comment -

        to keep it more polite than pete does:
        due to a current weld bug instances of Bean and CreationalContext aren't serializable. it worked in the past and hopefully they will fix it.
        esp. their implementation of CreationalContext implements Serializable but as soon as it isn't used as transient ref.var. it causes a NotSerializableException.
        also std. cdi constellations lead to a NotSerializableException with weld (v1.0.1) - example:

        public class SessionBeanProducer {

        @Produces
        @SessionScoped
        @Named("testBean")
        public TestBean createTestBean()

        { return new TestBean("test bean"); }

        }

        public class TestBean implements Serializable {

        private String value;

        public TestBean() {
        }

        public TestBean(String value)

        { this.value = value; }

        //+ getter/setter methods
        }

        we already have workarounds for weld bugs - currently it isn't planned to add further workarounds for the combination (weld and jboss-as6) because it's clearly a rudimentarily weld bug btw. a 2nd question is why jboss-as6 triggers the serialization.

        Show
        gpetracek Gerhard Petracek added a comment - to keep it more polite than pete does: due to a current weld bug instances of Bean and CreationalContext aren't serializable. it worked in the past and hopefully they will fix it. esp. their implementation of CreationalContext implements Serializable but as soon as it isn't used as transient ref.var. it causes a NotSerializableException. also std. cdi constellations lead to a NotSerializableException with weld (v1.0.1) - example: public class SessionBeanProducer { @Produces @SessionScoped @Named("testBean") public TestBean createTestBean() { return new TestBean("test bean"); } } public class TestBean implements Serializable { private String value; public TestBean() { } public TestBean(String value) { this.value = value; } //+ getter/setter methods } we already have workarounds for weld bugs - currently it isn't planned to add further workarounds for the combination (weld and jboss-as6) because it's clearly a rudimentarily weld bug btw. a 2nd question is why jboss-as6 triggers the serialization.
        Hide
        gpetracek Gerhard Petracek added a comment - - edited

        if the weld-team will fix the producer bug and the CreationalContext bug (or if they are already fixed with weld 1.1.x) and the weld-team won't change the Bean implementation, we have to use the SerializableBean trick of owb for ConversationBeanEntry

        possible workaround:
        a custom implementation of BeanEntryFactory (just works if the CreationalContext is serializable again)

        Show
        gpetracek Gerhard Petracek added a comment - - edited if the weld-team will fix the producer bug and the CreationalContext bug (or if they are already fixed with weld 1.1.x) and the weld-team won't change the Bean implementation, we have to use the SerializableBean trick of owb for ConversationBeanEntry possible workaround: a custom implementation of BeanEntryFactory (just works if the CreationalContext is serializable again)
        Hide
        gpetracek Gerhard Petracek added a comment -

        changed to minor (because there is a possible workaround)

        Show
        gpetracek Gerhard Petracek added a comment - changed to minor (because there is a possible workaround)
        Hide
        zoigl Thomas Andraschko added a comment -

        Did anyone created a ticket in jboss jira for this issue or is there a workaround available?
        I can not get any information on this issue which is very weird because it is not possible to use simple @ViewScoped bean...

        Show
        zoigl Thomas Andraschko added a comment - Did anyone created a ticket in jboss jira for this issue or is there a workaround available? I can not get any information on this issue which is very weird because it is not possible to use simple @ViewScoped bean...
        Hide
        gpetracek Gerhard Petracek added a comment -

        if you use the latest version of weld, it should work.
        + we implemented a workaround for weld (see EXTCDI-152)
        if you have to use glassfish, you have to take care which version you are using.

        Show
        gpetracek Gerhard Petracek added a comment - if you use the latest version of weld, it should work. + we implemented a workaround for weld (see EXTCDI-152 ) if you have to use glassfish, you have to take care which version you are using.
        Hide
        tandraschko Thomas Andraschko added a comment -

        It does not work with Weld 1.1.2-SNAPSHOT! (I don't use codi in this project, i just commented this issue to get more information)

        Show
        tandraschko Thomas Andraschko added a comment - It does not work with Weld 1.1.2-SNAPSHOT! (I don't use codi in this project, i just commented this issue to get more information)
        Hide
        fkj Felipe Jaekel added a comment -

        I get the following using Tomcat 7.0.29 + Wald 1.1.8.Final

        Ago 17, 2012 4:47:25 PM org.apache.catalina.session.StandardSession writeObject
        WARNING: Cannot serialize session attribute com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap for session 1A7EEF7A3654DE628A2206C80DBBADD0
        java.io.NotSerializableException: org.jboss.weld.bean.ManagedBean
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
        at java.util.concurrent.ConcurrentHashMap.writeObject(ConcurrentHashMap.java:1518)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
        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 java.util.HashMap.writeObject(HashMap.java:1100)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
        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.writeArray(ObjectOutputStream.java:1362)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1170)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
        at java.util.HashMap.writeObject(HashMap.java:1100)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174)
        at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1362)
        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1170)
        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346)
        at java.util.HashMap.writeObject(HashMap.java:1100)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
        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 java.util.HashMap.writeObject(HashMap.java:1100)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975)
        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480)
        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:5474)
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
        at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1575)
        at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1564)
        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)

        Show
        fkj Felipe Jaekel added a comment - I get the following using Tomcat 7.0.29 + Wald 1.1.8.Final Ago 17, 2012 4:47:25 PM org.apache.catalina.session.StandardSession writeObject WARNING: Cannot serialize session attribute com.sun.faces.renderkit.ServerSideStateHelper.LogicalViewMap for session 1A7EEF7A3654DE628A2206C80DBBADD0 java.io.NotSerializableException: org.jboss.weld.bean.ManagedBean at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1180) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346) at java.util.concurrent.ConcurrentHashMap.writeObject(ConcurrentHashMap.java:1518) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480) 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 java.util.HashMap.writeObject(HashMap.java:1100) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174) 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.writeArray(ObjectOutputStream.java:1362) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1170) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346) at java.util.HashMap.writeObject(HashMap.java:1100) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1416) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1174) at java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1362) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1170) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:346) at java.util.HashMap.writeObject(HashMap.java:1100) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480) 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 java.util.HashMap.writeObject(HashMap.java:1100) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:975) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1480) 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:5474) at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232) at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1575) at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1564) 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)

          People

          • Assignee:
            Unassigned
            Reporter:
            michaelschuetz Michael Schuetz
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development