Results 1 to 3 of 3
  1. #1
    bunny is offline Member
    Join Date
    Aug 2010
    Rep Power

    Default Using Spring AOP based transaction with Struts1

    Hi Friends,

    I am developing one application using Struts1.3+Spring2.5+Hibernate3.6 to do practice.
    In this application I am using Spring AOP transactions, but transaction is not working for me.

    Please check my code snippets and help me.

    in addition to general entries, I have added the following code as well


    <listener-class>org.springframework.web.context.ContextLoade rListener</listener-class>

    <bean id="transactionManager"
    class="org.springframework.orm.hibernate3.Hibernat eTransactionManager">
    <property name="sessionFactory" ref="mySessionFactory" />

    <bean id="matchAllWithSave"
    class="org.springframework.transaction.interceptor .NameMatchTransactionAttributeSource" lazy-init='true'>
    <property name="properties">
    <prop key="save*">
    <prop key="start*">
    <prop key="newTx*">
    <prop key="*">PROPAGATION_SUPPORTS,readOnly</prop>
    <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.Hibernat eInterceptor">
    <property name="sessionFactory" ref="mySessionFactory" />
    <bean id="matchSaveTxInterceptor"
    class="org.springframework.transaction.interceptor .TransactionInterceptor" lazy-init="true">
    <property name="transactionManager"><ref bean="transactionManager"/></property>
    <property name="transactionAttributeSource"><ref bean="matchAllWithSave"/></property>

    <bean id="autoProxyCreator"
    class="com.mokjas.extra.InterfaceAutoProxyCreator" lazy-init="true">
    <property name="interceptorNames">
    <idref local="matchSaveTxInterceptor"/>
    <idref local="hibernateInterceptor"/>

    <property name="interfaces">
    <value>com.mokjas.service.ITransactionalSaveServic e</value>
    Here all my service classes implemented this "ITransactionalSaveService" marker interface. So as per the above configuration,any service class which has save* method should wrap with transactions. But for me it is not working.
    public class ServiceFinder {
    public static ApplicationContext getContext(HttpServletRequest httpRequest) {
    return WebApplicationContextUtils.getRequiredWebApplicati onContext(
    Struts Action class:
    here in my action class I am calling save* method of my service class(implemented ITransactionalSaveService)

    transferService.saveAccountTransfer(fromBean, toBean);
    ServiceImpl class:

    public void saveAccountTransfer(UserBean fromBean,UserBean toBean){
    // TODO Auto-generated method stub


    DAO Impl class:
    public void processTransfer(UserBean bean, String name) {
    Session session=getSessionFactory().openSession();

    After we execute this
    my hibernate is not saving the beans accordingly because there is no transaction applied. so hibernate is generating only select statement,not update statement.

    Please help me to solve my issue.


  2. #2
    noctarius is offline Member
    Join Date
    Jun 2012
    Remscheid, Germany
    Rep Power

    Default Re: Using Spring AOP based transaction with Struts1

    Isn't one of both threads enough?

  3. #3
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: Using Spring AOP based transaction with Struts1

    True, I'm going to close this one as I think the Spring forum is the better bet for this, though this is a bit of a cross cutting question (which is slightly ironic).
    Here's a link to it in case anyone stumbles across this one.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Struts1
    By IsaacDura in forum Web Frameworks
    Replies: 0
    Last Post: 03-26-2011, 03:52 PM
  2. free GUI builder/designer for web page based on Spring
    By albertkao in forum Web Frameworks
    Replies: 0
    Last Post: 04-24-2010, 02:38 AM
  3. Difference between struts1 and struts2
    By radhika123 in forum Advanced Java
    Replies: 1
    Last Post: 10-30-2008, 12:04 PM
  4. Replies: 0
    Last Post: 04-01-2008, 10:45 AM
  5. Replies: 0
    Last Post: 10-04-2007, 09:17 PM

Tags for this Thread

Posting Permissions

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