Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Virgo » Hibernate Session Factory
Hibernate Session Factory [message #900813] Wed, 08 August 2012 15:09
Jens L. is currently offline Jens L.Friend
Messages: 1
Registered: August 2012
Junior Member
Hi there,

i am currently stuck with problem acquiring a valid hibernate session in my bean:

The error:

Constructor threw exception; nested exception is org.hibernate.HibernateException: No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

My spring-context.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans ...>
    <bean id="ds" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
        <property name="driverClassName" value="org.postgresql.Driver" />
        <property name="url" value="jdbc:postgresql:db" />
        <property name="username" value="xxx" />
        <property name="password" value="xxx" />

    <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="ds" />
        <property name="annotatedClasses">
        <property name="hibernateProperties">
                <prop key="">validate</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="javax.persistence.validation.mode">NONE</prop>
                <prop key="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</prop>

    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
        <constructor-arg name="sessionFactory" ref="sessionFactory" />
    <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

    <context:component-scan base-package="com.test"/>
    <tx:annotation-driven transaction-manager="transactionManager"/>


My Simple Test-Bean:

@Transactional(propagation=Propagation.SUPPORTS, readOnly=true)
public class SimpleDao {
    SessionFactory sf;
    public SimpleDao(SessionFactory sf) {
        this.sf = sf;
    public void demo() {
        Session session = sf.getCurrentSession();
        Query query = session.createSQLQuery("select * from customers").setResultTransformer(AliasToEntityMapResultTransformer.INSTANCE);


Maybe someone can shed some light on what the problem is.

Thanks in advance.

Best regards,
Previous Topic:Configure Virgo to identify Web Context correct path
Next Topic:Exceptions injecting reserved beans in Blueprint
Goto Forum:

Current Time: Mon May 28 03:29:00 GMT 2018

Powered by FUDForum. Page generated in 0.01303 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top