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.

Can a MailSender participate in a transaction?

Apr 25th, 2011, 10:59 AM

Hello,
I would like for my mailAbonne method to be fully transactional. I noticed that even on a MailException being thrown the data is persisted by the dao (dao.persistMailingAbonnee(ma);). What's wrong with my configuration?
Can anyone please help?
Thanks in advance,
Julien.

Comment

It blocks on log.error??? What logging system are you using? I can't imagine any of the common logging systems doing that. Are you absolutely sure about what you're seeing? Try adding in some System.out.println(...) statements around it and other suspicious lines. You've got something bizzar happening.

Fire up a debugger and walk through it line by line until you find the root method where it's blocking.

Incidentally RuntimeException and Error (and subclasses) all trigger a rollback automatically, no need to define it in rollbackFor (unless you really just like being overly explicit about things). Checked exceptions do not trigger a rollback by default, so if you re-threw MailSendException, you'd have to define rollbackFor=MailSendException.