This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Need advice on @Transactional

I have annotated my a service method (meaning it is annotated with @RequestMapping) with @Transactional(readOnly=false), i.e. this method has two annotations: @RequestMapping and @Transactional.

In the method, I explicitly throw a new RuntimeException() by catching unchecked exceptions bubbled up, just to be sure that a rollback can be triggered in case it is needed.

The method functions correctly in my test cases, until the cases created for testing transaction management. One of such case is to fail an database insert statement, in which a database (jdbcTemplate) error did occur, caught by the method, and a RuntimeException was thrown.

This piece of code works when I tested in a standalone environment (Eclipse, test run started by a "main" in the class). However, rollback did not occur in a server environment, where the method was executed by a web service call (recall that it is annotated by @RequestMapping). In fact, I could not detect any sign in my log (I use log4j) on server that transaction management is working in the server environment.

My server runs jboss 6 (an Openshift environment).

Because differences in standalone and server environments ("main block" v.s. web service call, and different dataSource defns), two different applicationContext.xml were used. I did make sure that two contexts are identical w.r.t transaction management, i.e. "txManager" definition, and "tx:annotation-driven" statement.

Any advice on possible causes, and/or "what/where to check" are greatly appreciated.

Since i have received no response, I am rephrasing my "plea-for-help" to see if I can make my question clearer.

To manage transactions by annotation, I performed 3 things:
1. I added the following line to my applicationContext.xml:
<tx:annotation-driven transaction-manager="txManager" proxy-target-class="true"/>
2. I annotated the methods which are transactional, mostly by
@Transactional (readOnly=false, propagation=Propagation.REQUIRED, isolation=Isolation.READ_COMMITTED)
3. In my application, whenever an event should result in a rollback, I explicitly throw a runtime exception
"throw new RuntimeException();"

When I tested on my local server on which the (@Transactional) annotated method was called from main, rollback seems fine.
However, when I tested it on a server, on which the the annotated method was called as a service (the method is also annotated by "@RequestMapping", rollback did not happen. More intriguingly, the RuntimeException was not intercepted by proxy (because it showed up in log) and I could find any sign in the log that transaction management was ever activated.

Question: because above mentioned 3 things, do I need to do anything else in order to activate transaction management (by annotation) in a server environment? Have I missed any subtle things?