Hi there,
I'm trying to get my spring DAOs to work but I only get this exception
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'sessionFactory' 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 applicationContext.xml looks like this
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
<bean id="ds1Datasource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jdbc/ds1"/>
</bean>
<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="db2Datasource"/>
<property name="mappingResources">
<list>
<value>hibernate/P1.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.DB2400Dialect
hibernate.connection.autocommit=false
hibernate.connection.charset=UTF-8
hibernate.show_sql=true
</value>
</property>
</bean>
<tx:annotation-driven transaction-manager="myTxManager"/>
<bean id="myTxManager" class="org.springframework.transaction.jta.JtaTransactionManager" />
<bean id="p1" class="dao.DomainP1Impl">
<property name="sessionFactory" ref="mySessionFactory" />
</bean>
And my DAO like this
@Transactional
public class DomainP1Impl implements DomainP1 {...}
What I'm doing wrong? Forgotten to mention: I'm using a JBoss AS 4.2.3