I am trying to invoke a DAO method inside my Stripes actionBean and I get the
following HibernateException. Not sure if I am missing any configuration
I appreciate any insights/pointers.
Thanks
-Srini
----------------------------
Unhandled exception caught by the Stripes default exception handler.
org.hibernate.HibernateException: No Hibernate Session bound to thread, and
configuration does not allow creation of non-transactional one here
at
org.springframework.orm.hibernate3.AbstractSessionFactoryBean$TransactionAwareI
nvocationHandler.invoke(AbstractSessionFactoryBean.java:29
----------------------------
public class MyActionBean extends BaseActionBean {
private CustomerService customerService;
@SpringBean("customerService")
public void injectCustomerService(CustomerService customerService){
this.customerService = customerService;
}
@DefaultHandler
public Resolution submit() {
//Call method on customerService which in turn calls method on DAO
//customerForm is POJO whose values are set at this point to be persisted
customerService.persistCustomerForm(customerForm);//This line throws Hib Ex!
//VERIFIED customerService is NOT null
return new ForwardResolution
(MyActionBean.class, "acknowledgment");
}
}
------------------
CustomerService.java:
********************
public interface CustomerService {
public CustomerForm persistCustomerForm(CustomerForm customerForm);
}
-----------------------
CustomerServiceImpl.java
**********************
public class CustomerServiceImpl implements CustomerService {
private CustomerFormDao customerFormDao; //with setters and getters
public CustomerForm persistCustomerForm(CustomerForm customerForm) {
return customerFormDao.persistCustomerForm(customerForm);
}
}
-----------------------------
Spring.xml
**********
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-
method="close">
<property name="driverClassName"
value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
....
</bean>
<bean id="namingStrategy" class="org.hibernate.cfg.ImprovedNamingStrategy"/>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:hibernate.xml" />
<property name="configurationClass"
value="org.hibernate.cfg.AnnotationConfiguration"/>
<property name="namingStrategy" ref="namingStrategy"/>
</bean>
<bean id="customerFormDao" class="com.my.dao.hibernate.CustomerFormDaoImpl" >
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<bean id="customerService" class="com.my.service.CustomerServiceImpl" >
<property name="customerFormDao" ref="customerFormDao" />
</bean>
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development