Announcement Announcement Module
No announcement yet.
No transaction aspect-managed TransactionStatus in scope Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • No transaction aspect-managed TransactionStatus in scope

    I am using Spring 2.0 framework, and spring IDE eclipse plugin.
    Please do have a look at the attached JPG file. Spring IDE shows (and I think)that I have properly coded spring bean config file.

    <beans xmlns=""
    	<!-- <bean/> definitions here -->
    	<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
    		<property name="url" value="jdbc:mysql://localhost:3306/soadb2"></property>
    		<property name="username" value="root"></property>
    		<property name="password" value="helloworld"></property>
    	<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    			<ref bean="dataSource"></ref>
    	<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        	<property name="dataSource" ref="dataSource"/>
      	<bean id="myStoredProcedure" class="">
    			<ref bean="dataSource"></ref>
    	<bean id="fooService" class="">
    			<ref bean="myStoredProcedure"/>
    	<tx:advice id="txAdvice" transaction-manager="txManager" >    
          		<tx:method name="*" />
    		<aop:pointcut id="fooServiceOperation" expression="execution (**())"/>
    		<aop:advisor advice-ref="txAdvice" pointcut-ref="fooServiceOperation" />

    public class FooService 
    	MyStoredProcedure myProc;
    	public FooService(MyStoredProcedure myProc) 
    		this.myProc = myProc;
    	public int generatePrimaryKey()
    		//MyStoredProcedure myProc = (MyStoredProcedure)MainClass.factory.getBean("myStoredProcedure");
    		Map results = myProc.execute();
    		Integer primKey = (Integer)results.get("primKey");
    		TransactionStatus status = TransactionAspectSupport.currentTransactionStatus();
    		System.out.println("Before executing set rollbackOnly");
    		System.out.println("After executing set rollbackOnly");
    		return primKey.intValue();

    In eclipse I got following stack trace--

    May 8, 2007 11:42:33 AM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
    INFO: Loading XML bean definitions from class path resource [beans-config.xml]
    May 8, 2007 11:42:33 AM org.springframework.jdbc.datasource.DriverManagerD ataSource setDriverClassName
    INFO: Loaded JDBC driver: com.mysql.jdbc.Driver
    Exception in thread "main" org.springframework.transaction.NoTransactionExcep tion: No transaction aspect-managed TransactionStatus in scope
    at org.springframework.transaction.interceptor.Transa ctionAspectSupport.currentTransactionStatus(Transa
    at ey(
    at springexample.MainClass.main(
    I am using MySQL 5.0 as DB. There were some concerns raised by developers that InnoDB should be running. I confirmed that is running.

    Any help would be great.


  • #2
    Hi Govinda,
    Did you resolve the Exception ? I'm also getting the same Exception while using "Declarative transaction management" of Spring. I've followed all steps specified at
    but dont know whats wrong. Is there any example on the net which I can check for Declarative /programmatic transaction management ? I've spend lot of time figuring out couldn't find a simple example showing how to use transaction management from Spring !!


    • #3
      Mistake I did was I assumed that ApplicationContext, ClassPathResource, FileSystemResource for instantiating container can be used to develop enterprise applications (eg, which need transaction support).

      Java Applications need to use ApplicationContext which adds more functionality to BeanFactory than, FileSystemResource or ClassPathResource.

      WebApplications should use WebApplicationContext; but for WebApp you need to configure listeners and other classes in web.xml

      Hope that helps.....



      • #4
        I think this information has made it into the new documentation for 2.1M3 so hopefully this will end this problem once and for all.
        Last edited by karldmoore; Aug 29th, 2007, 12:07 PM.