I have tried to configure declarative transaction management within my Spring-based web application and it refuses to cooperate with me.
I have two main problems:
So after hours upon hours of searching, debugging, and ripping my hair out, I finally stumbled upon this little gem which provided all the answers.
I never would have suspected something like that to be the issue but following the steps outlined in the above link worked perfectly.
Inside my dispatch-servlet.xml I had originally declared my component-scan as follows:
<context:component-scan base-package="foo.bar"/>
Which is a parent package to all of my application beans. So, as described in the link above, Spring was overwriting my transactional service beans from the applicationContext.xml with the service beans from the dispatcher-servlet.xml which did not know about the transactions.
All I did was break up the above component-scan to scan only the folders which contained non-transactional beans.
<context:component-scan base-package="foo.bar.controller"/>
<context:component-scan base-package="foo.bar.model"/>
<context:component-scan base-package="foo.bar.service.display"/>
<context:component-scan base-package="foo.bar.service.security"/>
<!-- foo.bar.service gets scanned in applicationContext.xml and includes
transactions so we must make sure to not include it here. The transactional beans
will be overridden in that case -->
After this my transactions worked exactly as expected and I was finally seeing footprints of the transactions and the DataSourceTransactionManager in my log files. This also fixed my first initial problem of the automatic rollbacks in the database. I guess it must have been closely tied with the lack of transactions.