Announcement Announcement Module
No announcement yet.
No bean named 'transactionManager' is defined Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • No bean named 'transactionManager' is defined

    Receiving a No bean named 'transactionManager' is defined

    1) Here is the Junit4 class(transactionManager has no space between n and s):

    @ContextConfiguration(locations = { "classpath:resources/Spring-Module.xml" })
    @TransactionConfiguration(transactionManager="tran sactionManager", defaultRollback=true)
    public class TestApp {

    CustomerDAO customerDAO;

    public void testDB() {

    Customer customer = new Customer(1, "mkyong", 28);
    Assert.assertEquals("Success", 1, 1);


    2) Below is the Spring configuration

    <beans xmlns=""

    <bean id="dataSource" class="org.springframework.jdbc.datasource.Transac tionAwareDataSourceProxy">
    <constructor-arg ref="dataSourceOrg"/>

    <bean id="dataSourceOrg" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3306/mkyongjava" />
    <property name="username" value="root" />
    <property name="password" value="xxxxxx />

    Last edited by java2design; Jun 3rd, 2013, 01:59 AM.

  • #2
    Do you have a transaction manager named transactionManager in your config?


    • #3
      The objective is to use Spring with legacy jdbc code. Therefore, wrapping datasource with TransactionAwareDataSourceProxy in the Spring config- see explanation below:

      Alternatively, you can allow application code to work with the standard J2EE-style lookup pattern DataSource.getConnection(), for example for legacy code that is not aware of Spring at all. In that case, define a TransactionAwareDataSourceProxy for your target DataSource, and pass that proxy DataSource to your DAOs, which will automatically participate in Spring-managed transactions when accessing it.


      • #4
        Read the stacktrace... It tells you what is missing, you don't have a transaction manager..

        Originally posted by java2design
        which will automatically participate in Spring-managed transactions when accessing it.
        And how do you think spring manages a transaction? Magic? No it needs a transaction manager.


        • #5
          Thanks for responding..what is the XML to add to the Spring-config for Transaction manager?


          • #6
            Depends on what technology you use, judging from your xml you are using plain JDBC.

            <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManagement">
              <property name="dataSource" ref="dataSourceOrg" />


            • #7
              I getting a Cannot find class [org.springframework.jdbc.datasource.DataSourceTran sactionManagement] when I added the above XML, yet it finds org.springframework.jdbc.datasource.DriverManagerD ataSource, which is in the same jar?


              • #8
                Thanks for responding Marten Deinum!

                Found the class not found issue. Did you mean:

                org.springframework.jdbc.datasource.DataSourceTran sactionManager

                instead of

                org.springframework.jdbc.datasource.DataSourceTran sactionManagement

                because class DataSourceTransactionManagement does not exist in jar file spring-jdbc.jar file


                • #9
                  That is indeed the class, not sure why I typed management instead of manager...


                  • #10
                    Thanks Marten - everything is now working!