3 Replies Latest reply on Jun 29, 2008 5:58 PM by System Administrator

    EJBTransactionRolledbackException: Session is closed

    tomek szzzaaos Newbie

      Hi Everyone,



      It's my first post, so just want to say hello to you all.


      I'm using FullTextQuery, as in the dvdstore example, but running into Exception:


      FATAL [application]javax.ejb.EJBTransactionRolledbackException: Session is closed!



      It happens when I try use the doSearch() method second time(first time it shows me results), is any of you got idea what can be wrong with code below?



           @Begin(join = true)
           public String doSearch() {
                currentPage = 0;
                updateResults();
      
                return "browse";
           }
      
           @SuppressWarnings("unchecked")
           private void updateResults() {
                FullTextQuery query;
                try {
                     query = searchQuery(searchQuery);
                } catch (ParseException pe) {
                     return;
                }
                //this works all the time
                List results2 = em.createQuery("select p from Part p").getResultList();
              for (Object o : results2){
                   System.out.println(o);
              }
                
                query.setMaxResults(pageSize + 1).setFirstResult(pageSize * currentPage);
                
                
      //------------->  session closed is thrown below
                List<Part> items =  query.getResultList();
                
                numberOfResults = query.getResultSize();
           
      
                if (items.size() > pageSize) {
                     searchResults = new ArrayList(items.subList(0, pageSize));
                     hasMore = true;
                } else {
                     searchResults = items;
                     hasMore = false;
                }
      
                searchSelections = new HashMap<Part, Boolean>();
           }
           
          private FullTextQuery searchQuery(String searchQuery) throws ParseException {
              String[] productFields = {"productCode", "description", "title"};
              QueryParser parser = new MultiFieldQueryParser(productFields, new StandardAnalyzer());
              parser.setAllowLeadingWildcard(true);
              org.apache.lucene.search.Query luceneQuery;
              luceneQuery = parser.parse(searchQuery);
              
              FullTextEntityManager ftem = (FullTextEntityManager) em; 
              
              return ftem.createFullTextQuery(luceneQuery, Part.class);
          }
      



      It throws:


      17:47:13,441 FATAL [application] javax.ejb.EJBTransactionRolledbackException: Session is closed!
      javax.faces.el.EvaluationException: javax.ejb.EJBTransactionRolledbackException: Session is closed!
           at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
           at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
           at javax.faces.component.UICommand.broadcast(UICommand.java:383)
           at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:184)
           at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:162)
           at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:350)
           at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:97)
           at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
           at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
           at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:416)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
           at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:85)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
           at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
           at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
           at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
           at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
           at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
           at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
           at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
           at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
           at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
           at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
           at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
           at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
           at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
           at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
           at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
           at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
           at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
           at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
           at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
           at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.ejb.EJBTransactionRolledbackException: Session is closed!... 
      ...
      17:47:13,443 WARN  [lifecycle] #{search.doSearch}: javax.ejb.EJBTransactionRolledbackException: Session is closed!
      javax.faces.FacesException: #{search.doSearch}: javax.ejb.EJBTransactionRolledbackException: Session is closed!
      ...
      Caused by: javax.faces.el.EvaluationException: javax.ejb.EJBTransactionRolledbackException: Session is closed!
           at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:91)
           at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
           ... 48 more
      Caused by: javax.ejb.EJBTransactionRolledbackException: Session is closed!
           at org.jboss.ejb3.tx.Ejb3TxPolicy.handleInCallerTx(Ejb3TxPolicy.java:87)
      ...
      17:47:13,444 WARN  [lifecycle] executePhase(INVOKE_APPLICATION 5,com.sun.faces.context.FacesContextImpl@af574d) threw exception
      javax.faces.FacesException: #{search.doSearch}: javax.ejb.EJBTransactionRolledbackException: Session is closed!
           at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:105)
      ...
      17:47:13,458 ERROR [ExceptionFilter] handling uncaught exception
      javax.servlet.ServletException: #{search.doSearch}: javax.ejb.EJBTransactionRolledbackException: Session is closed!
      ...
      17:47:13,459 ERROR [ExceptionFilter] exception root cause
      javax.faces.FacesException: #{search.doSearch}: javax.ejb.EJBTransactionRolledbackException: Session is closed!
           at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:107)
      ...
      17:47:14,285 WARN  [lifecycle] phase(RENDER_RESPONSE 6,com.sun.faces.context.FacesContextImpl@e92aef) threw exception: javax.el.ELException: /file:/home/tszpinda/coding/seam/jboss-4.2.2.GA/server/default/deploy/webshop.ear/webshop.war/WEB-INF/lib/jboss-seam-debug.jar!/META-INF/debug.xhtml: null /file:/home/tszpinda/coding/seam/jboss-4.2.2.GA/server/default/deploy/webshop.ear/webshop.war/WEB-INF/lib/jboss-seam-debug.jar!/META-INF/debug.xhtml: null
      com.sun.facelets.compiler.TextInstruction.write(TextInstruction.java:50)
      ...
      




      Thank you for your time and any help!!


      Tomek