1 Reply Latest reply on Oct 21, 2010 12:29 PM by bemar

    Performing action with a:commandButton - EntityManger closed

    bemar

      Hello,


      I wan't to perform a action with my entity bean via a:commandButton but when the action calls the method in the bean the error


      Caused by: java.lang.IllegalStateException: EntityManager is closed



      is thrown. I'm using a standard seam-gen bean.


      The error


      Caused by: javax.el.ELException: /IncidentSearch.xhtml @124,48 value="#{incidentSearchList.calcResult}": Error reading 'calcResult' on type ch.bemar.creditfriend.action.IncidentSearchList_$$_javassist_seam_5
           at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:76)
           at javax.faces.component.UIOutput.getValue(UIOutput.java:184)
           ... 76 more
      Caused by: java.lang.IllegalStateException: EntityManager is closed
           at org.hibernate.ejb.EntityManagerImpl.getSession(EntityManagerImpl.java:66)
           at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:436)
           at org.hibernate.ejb.AbstractEntityManagerImpl.joinTransaction(AbstractEntityManagerImpl.java:431)
           at org.jboss.seam.persistence.EntityManagerProxy.joinTransaction(EntityManagerProxy.java:122)
           at org.jboss.seam.transaction.AbstractUserTransaction.enlist(AbstractUserTransaction.java:73)
           at org.jboss.seam.framework.EntityQuery.joinTransaction(EntityQuery.java:236)
           at org.jboss.seam.framework.EntityQuery.createQuery(EntityQuery.java:179)
           at org.jboss.seam.framework.EntityQuery.initResultList(EntityQuery.java:79)
           at org.jboss.seam.framework.EntityQuery.getResultList(EntityQuery.java:71)
           at ch.bemar.creditfriend.action.IncidentSearchList.getCalcResult(IncidentSearchList.java:73)
           at sun.reflect.GeneratedMethodAccessor953.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at org.jboss.seam.util.Reflections.invoke(Reflections.java:22)
           at org.jboss.seam.intercept.RootInvocationContext.proceed(RootInvocationContext.java:32)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:56)
           at org.jboss.seam.transaction.RollbackInterceptor.aroundInvoke(RollbackInterceptor.java:28)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.transaction.TransactionInterceptor$1.work(TransactionInterceptor.java:97)
           at org.jboss.seam.util.Work.workInTransaction(Work.java:47)
           at org.jboss.seam.transaction.TransactionInterceptor.aroundInvoke(TransactionInterceptor.java:91)
           at org.jboss.seam.intercept.SeamInvocationContext.proceed(SeamInvocationContext.java:68)
           at org.jboss.seam.core.MethodContextInterceptor.aroundInvoke(MethodContextInterceptor.java:44)
           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.JavaBeanInterceptor.interceptInvocation(JavaBeanInterceptor.java:185)
           at org.jboss.seam.intercept.JavaBeanInterceptor.invoke(JavaBeanInterceptor.java:103)
           at ch.bemar.creditfriend.action.IncidentSearchList_$$_javassist_seam_5.getCalcResult(IncidentSearchList_$$_javassist_seam_5.java)
           at sun.reflect.GeneratedMethodAccessor952.invoke(Unknown Source)
           at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
           at java.lang.reflect.Method.invoke(Unknown Source)
           at javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
           at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
           at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:72)
           at org.jboss.el.parser.AstPropertySuffix.getValue(AstPropertySuffix.java:53)
           at org.jboss.el.parser.AstValue.getValue(AstValue.java:67)
           at org.jboss.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
           at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
           ... 77 more




      My xhmtl file


      <a:status id="globalStatus" 
                          onstart="Richfaces.showModalPanel('loading', {width:'70x', height:'70px'});"
                          onstop="Richfaces.hideModalPanel('loading');" />
      
      <rich:simpleTogglePanel label="#{messages.text_foundincidents}"
                          switchType="ajax">
      
                          <s:decorate id="foundPersonField" template="layout/edit.xhtml">
                               <ui:define name="label">Person gefunden</ui:define>
                               <h:outputText id="foundPerson" size="45"
                                    value="#{incidentSearchList.calcResult}">                              
                               </h:outputText>
                          </s:decorate>
                     </rich:simpleTogglePanel>
      
      
      <a:commandButton id="infotext"
                          value="a:#{messages.text_search}"
                          disabled="#{incidentSearchList.incidentSearch.validInput==false}"
                          status="globalStatus" reRender="foundPersonField"/> 




      The bean




      /**
           * Get the list of results this query returns
           * 
           * Any changed restriction values will be applied
           */
          @Transactional
          public Integer getCalcResult()
          {
              System.out.println(incidentSearch);
              List<Incident> incidentList = super.getResultList();
              this.foundPersons = incidentList.size();
              return this.foundPersons;
          }



      What could be the problem?


      Thx for your help


      Ben