Results 1 to 3 of 3

Thread: Running Out of Hibernate Sessions...SessionHolder.getAnySess

  1. #1
    Join Date
    Oct 2004
    Posts
    16

    Default Running Out of Hibernate Sessions...SessionHolder.getAnySess

    In a WebLogic container...we are running out of Hibernate Sessions and experiencing the exception below:

    com.level3.sldb.common.SLDBException: Error calling getCustomerProfileValues from SomaManager.java.util.NoSuchElementException at java.util.HashMap$HashIterator.nextEntry(HashMap.j ava:765) at java.util.HashMap$ValueIterator.next(HashMap.java: 792) at org.springframework.orm.hibernate.SessionHolder.ge tAnySession(SessionHolder.java:70) at org.springframework.orm.hibernate.SessionFactoryUt ils.getSession(SessionFactoryUtils.java:293) at org.springframework.orm.hibernate.SessionFactoryUt ils.getSession(SessionFactoryUtils.java:248) at org.springframework.orm.hibernate.SessionFactoryUt ils.getSession(SessionFactoryUtils.java:205) at org.springframework.orm.hibernate.HibernateTemplat e.execute(HibernateTemplate.java:191) at org.springframework.orm.hibernate.HibernateTemplat e.saveOrUpdate(HibernateTemplate.java:341) at com.level3.sldb.framework.dao.DAOAudit.storeAuditC orrelation(DAOAudit.java:30) at com.level3.sldb.spring.interceptor.AuditIntercepto r.invoke(AuditInterceptor.java:82) a

    --------------------------------------------------------------------

    I am using EJB - Spring/Hibernate. Configuration Below:

    <!-- Hibernate Session Factory -->
    <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSess ionFactoryBean">
    <property name="dataSource"><ref bean="dataSource"/></property>
    <property name="mappingResources">
    <list> <value>com/level3/sldb/framework/dao/dto/AuditCorrelationDTO.hbm.xml</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">net.sf.hibernate.dialect.O racle9Dialect</prop>
    <prop key="hibernate.transaction.manager_lookup_class">n et.sf.hibernate.transaction.WeblogicTransactionMan agerLookup</prop>
    </props>
    </property>
    </bean>

    The DataSource is a WebLogic TxJdbcDataSource.


    Class File:

    public class DAOAudit extends HibernateDaoSupport implements DAOAuditIF {

    public void storeAuditCorrelation(AuditCorrelationDTO correlation) throws DataAccessException {
    getHibernateTemplate().saveOrUpdate(correlation);
    }

    Thanks in advance.

  2. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    What is your transaction strategy? The problem appears to be that your code is producing a multitude of sessions because there's no transaction scope and no session is ever bound to the current thread. In fact you want one session per transaction.

    Please look at the Spring Hibernate examples to see how to configure Hibernate with tx mgt. You need to use JtaTransactionManager if you want to work with a WebLogic tx DataSource.

    Note that if you want to mix Hibernate with EJB CMT you should not be using LocalSessionFactoryBean but configuring your Hibernate SessionFactory using JCA. Spring's transaction support (even with JTA) will know about LocalSessionFactoryBean, but the EJB container won't. However, I would recommend using Spring's transaction management in preference to EJB CMT in general.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Aug 2004
    Location
    Toronto, Canada
    Posts
    736

    Default

    Actually, for the EJB CMT case, there should be no issues using LocalSessionFactoryBean, but it is critical that Hibernate's TransactionManagerLookup is set properly in the SessionFactory. This is because you will normally not be using Spring's JTATransactionManager, so Spring's hibernate code and Hibernate itself need to be able to find and coordinate with the container managed JTA transaction manager, instead of Spring's JTATransactionManager, that would normally have that role.
    Colin Sampaleanu
    SpringSource - http://www.springsource.com

Similar Threads

  1. Replies: 5
    Last Post: Dec 27th, 2005, 07:00 AM
  2. Loosing my SecureContext
    By sklakken in forum Security
    Replies: 3
    Last Post: Jul 21st, 2005, 01:44 PM
  3. Replies: 1
    Last Post: Jul 5th, 2005, 03:48 AM
  4. Replies: 8
    Last Post: Jan 22nd, 2005, 04:31 AM
  5. Replies: 3
    Last Post: Nov 19th, 2004, 07:16 PM

Posting Permissions

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