Results 1 to 4 of 4

Thread: Hibernate/Interceptor Not Bound

  1. #1
    Join Date
    Mar 2007
    Posts
    113

    Default 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. #2
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    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 at 11:59 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

  3. #3
    Join Date
    Mar 2007
    Posts
    113

    Default

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

    thanks.

  4. #4
    Join Date
    Sep 2006
    Location
    UK
    Posts
    8,424

    Default

    Quote 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 at 11:59 AM.
    Barracuda Networks SSL VPN Lead Developer
    http://pramatr.wordpress.com
    http://twitter.com/karldmoore
    http://www.linkedin.com/in/karldmoore
    Any postings are my own opinion, and should not be attributed to my employer or clients.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •