1 Reply Latest reply on May 14, 2008 2:38 PM by gaboo.gael.livre-rare-book.com

    problem passivation thread - EntityManager is closed

    gaboo.gael.livre-rare-book.com

      Hello,


      I have the following error for several of my stateful EJB.
      I've been looking for some help/informatino on google/this forum, jboss, etc for some time and I'm out of ideas.


      It happens some minutes after I use them. All in one go, for all of them.


      I've check that :



      • it implements serializable

      • it uses @PersistenceContext for entityManager

      • all members are serializable

      • injected facesContext is annotated transient

      • added @Transient to non serializable objects




      16:59:35,236 ERROR [ImportManagerImpl] problem passivation thread
      java.lang.RuntimeException: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.web.session
              at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.prePassivate(LifecycleInterceptorHandler.java:169)
              at org.jboss.ejb3.stateful.StatefulContainer.invokePrePassivate(StatefulContainer.java:415)
              at org.jboss.ejb3.stateful.StatefulBeanContext.prePassivate(StatefulBeanContext.java:365)
              at org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:371)
              at org.jboss.ejb3.cache.simple.SimpleStatefulCache.passivate(SimpleStatefulCache.java:301)
              at org.jboss.ejb3.cache.simple.SimpleStatefulCache$SessionTimeoutTask.run(SimpleStatefulCache.java:209)
      Caused by: org.jboss.seam.InstantiationException: Could not instantiate Seam component: org.jboss.seam.web.session
              at org.jboss.seam.Component.newInstance(Component.java:1983)
              at org.jboss.seam.Component.getInstance(Component.java:1873)
              at org.jboss.seam.Component.getInstance(Component.java:1852)
              at org.jboss.seam.Component.getInstance(Component.java:1829)
              at org.jboss.seam.web.Session.getInstance(Session.java:122)
              at org.jboss.seam.contexts.Contexts.flushAndDestroyContexts(Contexts.java:375)
              at org.jboss.seam.contexts.Lifecycle.endCall(Lifecycle.java:96)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:122)
              at org.jboss.seam.intercept.RootInterceptor.invokeAndHandle(RootInterceptor.java:84)
              at org.jboss.seam.intercept.SessionBeanInterceptor.prePassivate(SessionBeanInterceptor.java:56)
              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.jboss.ejb3.interceptor.LifecycleInvocationContextImpl.proceed(LifecycleInvocationContextImpl.java:131)
              at org.jboss.ejb3.interceptor.LifecycleInterceptorHandler.prePassivate(LifecycleInterceptorHandler.java:165)
              ... 5 more
      Caused by: javax.ejb.EJBException: java.lang.IllegalStateException: EntityManager is closed
              at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:63)
              at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:83)
              at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:191)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:95)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessInstanceInterceptor.invoke(StatelessInstanceInterceptor.java:62)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:77)
              at org.jboss.ejb3.security.Ejb3AuthenticationInterceptor.invoke(Ejb3AuthenticationInterceptor.java:110)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:46)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:106)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:240)
              at org.jboss.ejb3.stateless.StatelessContainer.localInvoke(StatelessContainer.java:210)
              at org.jboss.ejb3.stateless.StatelessLocalProxy.invoke(StatelessLocalProxy.java:84)
              at $Proxy950.createSession(Unknown Source)
              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.jboss.seam.util.Reflections.invoke(Reflections.java:21)
              at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:31)
              at org.jboss.seam.intercept.ClientSideInterceptor$1.proceed(ClientSideInterceptor.java:76)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.ClientSideInterceptor.invoke(ClientSideInterceptor.java:54)
              at org.javassist.tmp.java.lang.Object_$$_javassist_9.createSession(Object_$$_javassist_9.java)
              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.jboss.seam.util.Reflections.invoke(Reflections.java:21)
              at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
              at org.jboss.seam.Component.callComponentMethod(Component.java:2089)
              at org.jboss.seam.core.Events.raiseEvent(Events.java:84)
              at org.jboss.seam.Component.newInstance(Component.java:1976)
              ... 20 more
      Caused by: java.lang.IllegalStateException: EntityManager is closed
              at org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:42)
              at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:448)
              at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:443)
              at org.jboss.seam.persistence.EntityManagerProxy.joinTransaction(EntityManagerProxy.java:120)
              at org.jboss.seam.transaction.AbstractUserTransaction.enlist(AbstractUserTransaction.java:73)
              at org.jboss.seam.persistence.ManagedPersistenceContext.joinTransaction(ManagedPersistenceContext.java:123)
              at org.jboss.seam.persistence.ManagedPersistenceContext.getEntityManager(ManagedPersistenceContext.java:112)
              at sun.reflect.GeneratedMethodAccessor2136.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.seam.util.Reflections.invoke(Reflections.java:21)
              at org.jboss.seam.util.Reflections.invokeAndWrap(Reflections.java:125)
              at org.jboss.seam.Component.callComponentMethod(Component.java:2089)
              at org.jboss.seam.Component.unwrap(Component.java:2115)
              at org.jboss.seam.Component.getInstance(Component.java:1887)
              at org.jboss.seam.Component.getInstance(Component.java:1840)
              at org.jboss.seam.Component.getInstanceInAllNamespaces(Component.java:2189)
              at org.jboss.seam.Component.getValueToInject(Component.java:2141)
              at org.jboss.seam.Component.injectAttributes(Component.java:1598)
              at org.jboss.seam.Component.inject(Component.java:1416)
              at org.jboss.seam.core.BijectionInterceptor.aroundInvoke(BijectionInterceptor.java:45)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.bpm.BusinessProcessInterceptor.aroundInvoke(BusinessProcessInterceptor.java:49)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.EventInterceptor.aroundInvoke(EventInterceptor.java:51)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:42)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.persistence.EntityManagerProxyInterceptor.aroundInvoke(EntityManagerProxyInterceptor.java:26)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.persistence.HibernateSessionProxyInterceptor.aroundInvoke(HibernateSessionProxyInterceptor.java:27)
              at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
              at org.jboss.seam.intercept.RootInterceptor.invoke(RootInterceptor.java:107)
              at org.jboss.seam.intercept.SessionBeanInterceptor.aroundInvoke(SessionBeanInterceptor.java:50)
              at sun.reflect.GeneratedMethodAccessor2192.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:597)
              at org.jboss.ejb3.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:118)
              at org.jboss.ejb3.interceptor.EJB3InterceptorsInterceptor.invoke(EJB3InterceptorsInterceptor.java:63)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.entity.TransactionScopedEntityManagerInterceptor.invoke(TransactionScopedEntityManagerInterceptor.java:54)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.ejb3.AllowedOperationsInterceptor.invoke(AllowedOperationsInterceptor.java:47)
              at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:101)
              at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:79)
              ... 57 more



      An example EJB :


      @Stateful
      @Name("advancedSearchEngine")
      @Scope(ScopeType.CONVERSATION)
      public class AdvancedSearchEngineImpl implements AdvancedSearchEngine, Serializable {
      
              private static final long serialVersionUID = -5971478948231832007L;
      
              @Out
              @In(create = true)
              private Query query;
      
              @Out(required = false)
              List<Topic> relatedTopics;
      
              @RequestParameter
              private Long queryId;
      
              @Logger
              @Transient
              Log log;
      
              @PersistenceContext
              private EntityManager entityManager;
      
              @In
              @Transient
              private FacesContext facesContext;
      
              @RequestParameter
              private String bookId;
      
              private Integer firstResult = 0;
              private Integer lastFirstResult;
      
              private Integer nextFirstResult;
              private Integer previousFirstResult;
      
              private boolean previousExists;
              private boolean nextExists;
      
              @Transient
              private List<Result> resultList;
      
              private Integer total;
              private Integer totalFound;
      
              private int pageCount;
              private int maxResultPerPage;
              private int currentPage;
      
              private boolean firstLoad = true;
      
              private String topicKeycode;
      
              private String thesaurusStringId;
      
              public AdvancedSearchEngineImpl() {
                      resultList = new ArrayList<Result>();
              }
      
              @Remove
              public void destroy() {
              }
      [ ... some getter and setter and public methods ... ]
      
      

        • 1. Re: problem passivation thread - EntityManager is closed
          gaboo.gael.livre-rare-book.com

          I've tested my EJB with this to check that they are serializable :



          public void testIsSerializable() throws IOException {
                    AdvancedSearchEngine advSE = (AdvancedSearchEngine) Component
                              .getInstance(AdvancedSearchEngineImpl.class);
          
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    ObjectOutputStream oos = new ObjectOutputStream(out);
                    oos.writeObject(advSE);
                    oos.close();
                    System.out.println("OOS length : " + out.toByteArray().length);
          
               }



          And they are. So is does not seam related to this.