3 Replies Latest reply on Apr 28, 2008 9:40 AM by Sebastian Hennebrueder

    precedence problem Hibernate Session versus Seam Session

    Sebastian Hennebrueder Newbie

      Hello,


      I found a precedence problem and I am not sure is this turns out to be a general problem in a lot of core components (or me not understanding something).


      I try to inject the Hibernate session in my components using session as name.
      @In
      private Session session


      With the following components.xml this leads to a classcastexception when the session is injected in the HibernateTransaction. Seam tries to inject a HTTP Session.


      components.xml


      <persistence:hibernate-session-factory name="hibernateSessionFactory"/>
      <persistence:managed-hibernate-session name="session"                       
       auto-create="true"        
      session-factory="#{hibernateSessionFactory}"/>
      <transaction:hibernate-transaction session="#{session}"/>
      



      In my opinion this is an error as the component is properly created.


      A workaround is possible. When injecting the session into the transaction the wrong component (Seam Session) is used.


      I created a factory for session.




        <factory name="session"
                 scope="STATELESS"
                 auto-create="true"
                 value="#{xsession}"/>
      <persistence:managed-hibernate-session name="xsession"
                                               auto-create="true"
      session-factory="#{hibernateSessionFactory}"/>
       <transaction:hibernate-transaction session="#{xsession}" />
      





      I tried to play with the precedence but this did not help as well.


      Best Regards / Viele Grüße


      Sebastian Hennebrueder


      -----
      http://www.laliluna.de


        • 2. Re: precedence problem Hibernate Session versus Seam Session
          Sebastian Hennebrueder Newbie

          15:31:24,466 ERROR SeamPhaseListener:120 - uncaught exception
          java.lang.IllegalStateException: Could not start transaction
               at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:581)
               at org.jboss.seam.jsf.SeamPhaseListener.handleTransactionsBeforePhase(SeamPhaseListener.java:312)
               at org.jboss.seam.jsf.SeamPhaseListener.beforeServletPhase(SeamPhaseListener.java:140)
               at org.jboss.seam.jsf.SeamPhaseListener.beforePhase(SeamPhaseListener.java:114)
               at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:222)
               at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
               at javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
               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.web.LoggingFilter.doFilter(LoggingFilter.java:58)
               at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
               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.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.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
               at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
               at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
               at java.lang.Thread.run(Thread.java:619)
          Caused by: java.lang.ClassCastException: org.apache.catalina.session.StandardSessionFacade cannot be cast to org.hibernate.Session
               at org.jboss.seam.transaction.HibernateTransaction.initSession(HibernateTransaction.java:69)
               at org.jboss.seam.transaction.HibernateTransaction.begin(HibernateTransaction.java:80)
               at org.jboss.seam.jsf.SeamPhaseListener.begin(SeamPhaseListener.java:576)
               ... 32 more

          • 3. Re: precedence problem Hibernate Session versus Seam Session
            Sebastian Hennebrueder Newbie

            This was a bug in Seam.


            Copied from Jira
                Fix Version/s: 2.0.2.CR2
                               2.1.0.BETA1



            Thank you for the fix.