Announcement Announcement Module
Collapse
No announcement yet.
Problem while using transaction in spring frame work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem while using transaction in spring frame work

    hi,
    i got a problem in using spring db declarative transaction.when i put my dao class in transaction i am getting exception while starting the server as

    "org.springframework.beans.factory.BeanDefinitionS toreException: Error registering bean with name 'test' defined in resource [/WEB-INF/applicationContext.xml] of ServletContext: Class that bean class [org.springframework.transaction.interceptor.Transa ctionProxyFactoryBean] depends on not found; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice"

    my code is as below

    the buisiness class from where i will be calling my dao
    --------------------------------------------------------------

    public void setDataAccessObject(TestSpring tst) {
    this.ts = tst;
    }
    public boolean CreateRetirementDataObject(RetirementPlanBean rpb) {

    try {
    ts.myQuery();
    return true;
    } catch (Exception e) {
    return false;
    }
    }

    my dao method
    ---------

    public String myQuery() {
    String name = "";

    try {

    jt = new JdbcTemplate();

    jt.setDataSource(dataSource);
    name =
    (String) jt.queryForObject(
    "select name from retiredb where Id=1",
    java.lang.String.class);



    } catch (Exception ee) {



    }

    return name;

    }

    //setting data source
    public void setDataSource(DataSource dataSource) {
    this.dataSource = dataSource;
    }


    and my entries in xml files applicationContext.xml
    --------------------------------

    <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
    <property name="locations">
    <list>
    <value>WEB-INF/jdbc.properties</value>
    </list>
    </property>
    </bean>

    <bean id="retirementBusinessObject" class="beans.RetirementBusinessObject">
    <property name="dataAccessObject"><ref bean="testSpring"/></property>
    </bean>

    <bean id="test" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="transactionManager"><ref bean="transactionManager"/></property>
    <property name="target"><ref local="retirementBusinessObject"/></property>
    <property name="transactionAttributes">
    <props>
    </props>
    </property>

    </bean>
    ----------------------------

    dataAcessContext-Local.xml
    ---------------------------------

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName"><value>sun.jdbc.odbc.JdbcOd bcDriver</value></property>
    <property name="url"><value>jdbc:odbc:Retirement</value></property>
    </bean>


    <bean id="testSpring" class="beans.TestSpring">
    <property name="dataSource"><ref local="dataSource"/></property>

    </bean>


    <bean id="transactionManager" class="org.springframework.transaction.PlatformTra nsactionManager">
    <property name="dataSource"><ref local="dataSource"/></property>
    </bean>

  • #2
    You need aopalliance.jar in you WEB-INF/lib directory. It is shipped with the Spring distribution.

    Comment

    Working...
    X