[jboss-user] [EJB 3.0] - requiresnew

Mr_Anonymous do-not-reply at jboss.com
Sun Feb 24 23:26:12 EST 2008

I have a 2 methods on a session bean:
1. void sendEmail(SomeEmailBean)  # marked as REQUIRED
2. void saveFailedEmailToDatabase(SomeEmailBean) # REQUIRESNEW

I want the first method to call the second internally when the email fails (ex: SMTP server down).  So I have:
try { // code to send email
catch (Exception e) {
  // lookup remote interface to EmailServiceBean (using remote on purpose to try to force the REQUIRESNEW)
  // call saveFailedEmailToDatabase method on the remote interface
  // throw a runtime exception at this point in case we are part of a larger transaction so it will rollback

.. now I have debug code in the saveFailedEmailToDatabase method, so I see it getting called from the catch block and I see it trying to write data to the database (I use db generated sequence #s and I see those getting populated after the db calls).  *But* when I actually look at the database the table is empty (which makes it look like the call on the remote interface is getting tied to the current transaction so it is rolling back).  Has anyone seen anything like this?  FYI: I'm on JBoss 4.2.1.

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4131730#4131730

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4131730

More information about the jboss-user mailing list