Announcement Announcement Module
Collapse
No announcement yet.
Hibernate/Interceptor Not Bound Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hibernate/Interceptor Not Bound

    Hi All...

    I'm trying to port Spring from 1.2.6 to 2.0.1. I have an Interceptor that extends LocalSessionFactoryBean.


    Code:
    <bean id="sessionFactory"  class="org.boa.finance.persistence.AuditSessionFactory">
            <property name="dataSource"><ref bean="dataSource"/></property>
            .....

    This is instantiated no problems. I have an operation in AuditSessionFactory that makes the call..

    Code:
    sessionFactory = (SessionFactory)localSessionFactory.getObject();
         final Session session = SessionFactoryUtils.getSession(sessionFactory,false);

    Here's some other info

    Code:
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
            <property name="sessionFactory"><ref bean="sessionFactory"/></property>
        </bean>
    
         <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
            <property name="sessionFactory"><ref bean="sessionFactory"/></property>
        </bean>

    This works fine in 1.2.6. When I try to run with 2.0.1, I notice during Jboss startup the following..

    [AuditSessionFactory] Building new Hibernate SessionFactory

    And then I get the error below...

    13:39:23,174 ERROR [LogInterceptor] EJBException in method: public abstract org.boa.finance.UserStatus[] org.boa.finance.ejb.SiteAuthorizationService.getAl lUserStatusCodes(), causedBy:
    java.lang.IllegalStateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here
    at org.springframework.orm.hibernate3.SessionFactoryU tils.doGetSession(S
    essionFactoryUtils.java:367)
    at org.springframework.orm.hibernate3.SessionFactoryU tils.getSession(Ses
    sionFactoryUtils.java:198)

    This is happening on the line

    Code:
    Session session = SessionFactoryUtils.getSession(sessionFactory, false);

    I tried passing true to getSession, but no luck.

    Any ideas are appreciated...thanks in advance!

  • #2
    It would be useful to see the code that makes up this flow and the configuration. It's always nice to see a test case which executes this. I'm slightly confused why you're getting the same exception even if you pass true in.
    Code:
    			// Check whether we are allowed to return the Session.
    			if (!allowCreate && !isSessionTransactional(session, sessionFactory)) {
    				closeSession(session);
    				throw new IllegalStateException("No Hibernate Session bound to thread, " +
    						"and configuration does not allow creation of non-transactional one here");
    			}
    Last edited by karldmoore; Aug 29th, 2007, 11:59 AM.

    Comment


    • #3
      Thanks for taking the time!...I looks like our util class was calling closeSession, instead of releaseSession. Sorry for the confusion...

      thanks.

      Comment


      • #4
        Originally posted by jnl001 View Post
        Thanks for taking the time!...I looks like our util class was calling closeSession, instead of releaseSession. Sorry for the confusion...
        Not a problem, thanks for posting back. It's always nice to find out what the problem actually was .
        Last edited by karldmoore; Aug 29th, 2007, 11:59 AM.

        Comment

        Working...
        X