4 Replies Latest reply on Nov 28, 2006 6:00 PM by Chris Lowe

    Possible to test Passivation from Embedded EJB3?

    Chris Lowe Apprentice


      I'm seeing quite a few of the following exceptions in my application:

      Could not activate; failed to restore state
       at org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.activateSession(StatefulSessionFilePersistenceManager.java:306)
       at org.jboss.ejb3.cache.simple.SimpleStatefulCache.get(SimpleStatefulCache.java:265)
      Caused by: java.lang.ClassCastException: org.jboss.serial.io.MarshalledObject
       at org.jboss.ejb3.stateful.StatefulBeanContext.readExternal(StatefulBeanContext.java:416)
       at org.jboss.serial.persister.ExternalizePersister.readData(ExternalizePersister.java:72)
       at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.readObjectDescriptionFromStreaming(ObjectDescriptorFactory.java:412)
       at org.jboss.serial.objectmetamodel.ObjectDescriptorFactory.objectFromDescription(ObjectDescriptorFactory.java:82)
       at org.jboss.serial.objectmetamodel.DataContainer$DataContainerDirectInput.readObject(DataContainer.java:643)
       at org.jboss.serial.io.JBossObjectInputStream.readObjectOverride(JBossObjectInputStream.java:163)
       at java.io.ObjectInputStream.readObject(ObjectInputStream.java:342)
       at org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.activateSession(StatefulSessionFilePersistenceManager.java:292)
       ... 100 more

      I am aware that there is a difference between timeouts of SFSB and HTTP session, the values of which I have aligned as per the discussion at the following:


      Still no joy.

      The next problem that could causes passivation errors is the fact that my stateful beans are not serializable either directly or indirectly due to a class member. Trying to recreate this outside of the application server is proving tricky since my beans naturally use the injection mechanisms of Seam. Therefore if I'm to test serialization properly, then I need to prepare the SFSBs in a SeamTest.

      This is where I'm stuck due to the generated beans that I get back from the mock context being proxies rather than instances of the beans. How can I test if my SFSBs are serializable? Am I able to instruct the embedded EJB3 container to passivate my bean and then reawaken it? Or is there a way to get at the underlying beans to serialize them myself? Or am I on the wrong track entirely? Basically, I need to track down the cause of the above exception and somehow try and prevent further problems from cropping up. Any suggestions?

      Best Regards,


        • 1. Re: Possible to test Passivation from Embedded EJB3?
          Gavin King Master

          You don't need to check serializability of @In fields, since they are nullified by Seam (1.1) at the end of the invocation.

          • 2. Re: Possible to test Passivation from Embedded EJB3?
            Chris Lowe Apprentice

            Yeah, I'd read that in the release notes and with a fix for JBSEAM-325 these were my main driver for upgrading to 1.1. So I am actually using Seam 1.1 CR1 now and the exception reported in my original post was for the following bean:

            public class ChangePasswordAction implements ChangePassword, Serializable{
             private static final long serialVersionUID = 1L;
             private Log log;
             @In(create=true) @Out
             private User user;
             private MessageUtils messageUtils;
             private PasswordUtils passwordUtils;
             private UserDao userDao;
             private AuditLog auditLog;
             private String password;
             private String confirmPassword;
             ... (remaining class consists of methods only)

            As you can see, if you strip the @In parameters from the class, we're left with two strings. I've tested the serializability of the class and it is okay.

            Am I right in thinking that the following exception (which was reported as preventing my bean from being activated) could be caused by serialization problems, or am I running into a different issue?

            Caused by: java.lang.ClassCastException: org.jboss.serial.io.MarshalledObject



            • 3. Re: Possible to test Passivation from Embedded EJB3?
              Gavin King Master

              Looks like a classloading problem to me, not a serializability problem.

              • 4. Re: Possible to test Passivation from Embedded EJB3?
                Chris Lowe Apprentice

                Ah yes - this was down to a mix in jboss-serialization.jar versions.