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.
Mark Spritzler wrote:Um, because you catch MailException, it will never throw MailException out of that method for the TransactionManager to roll it back.
If you catch it, you must re throw it if you want to release it out of the catch.
Mark
Good point! I should have spotted that. However when I remove the try/catch the exception is no longer thrown... Any idea why?
regards,
J.
Julien Martin
Ranch Hand
Joined: Apr 24, 2004
Posts: 384
posted
0
Hello Mark,
I changed my method to public as you advised. Here is how it looks now:
I get the same behavior as before...
Any other idea?
J.
<tx:annotation-driven/> tag in your configuration to tell Spring you are using the @Transactional annotations and therefore Spring will create a Proxy around your object to add Transactionlity to it?
OH, and that method is in your interface that that class implements?
Mark
Julien Martin
Ranch Hand
Joined: Apr 24, 2004
Posts: 384
posted
0
Mark Spritzler wrote:OH, and that method is in your interface that that class implements?
Mark
Yes it is indeed.
Julien Martin
Ranch Hand
Joined: Apr 24, 2004
Posts: 384
posted
0
Mark Spritzler wrote:Do you have a
<tx:annotation-driven/> tag in your configuration to tell Spring you are using the @Transactional annotations and therefore Spring will create a Proxy around your object to add Transactionlity to it?
Thanks
Mark
Yes it is too.
Julien Martin
Ranch Hand
Joined: Apr 24, 2004
Posts: 384
posted
0
The problem seems to be that the timeout is set to indefinitely on my mailsender although I tried to set it to 1 second as follows:
and so the method hangs indefinitely. Hence the rollback is not performed...
Anyone any other idea how to sort this out?
Regards,
J.
Julien Martin
Ranch Hand
Joined: Apr 24, 2004
Posts: 384
posted
0
Sorry it does time out but the method still hangs indefinitely. Here is what the log says:
But that isn't the Exception you are catching, unless MailSendException is a subclass of the Exception type that you are catching.
Mark
Julien Martin
Ranch Hand
Joined: Apr 24, 2004
Posts: 384
posted
0
Hi Mark,
I managed to isolate the problem. I now know it has nothing to do with the java mail api.
Here is my method:
I deliberately throw a RuntimeException from the envoyerMail method and it hangs where it is noted //here. I also know that Spring does create the beans properly and advises them propertly according to the @Transactional annotation because it says so in the logs. It is as if my method wouldn't manage to rethow the RuntimeException...
What could I be getting wrong?
Julien.