[jboss-user] [JBoss Seam] - Re: Exception Handling (w/ interceptor)
Well, I'll see if I can package up an example, but with my luck, it will not work as I described... :-) View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3971612#3971612 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971612 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Exception Handling (w/ interceptor)
anonymous wrote : I did get this working, but I had to back out the Seam jars from CVS, as I couldn't figure out how to avoid hitting the Seam "ExceptionInterceptor". @Interceptor(within=ExceptionInterceptor.class) anonymous wrote : One question - how did the Seam ExceptionInterceptor class bypass my "catch" clause? In the "save()" method that I included above, the catch clause was never reached if I used the 9/10/2006 CVS jars. Instead, the Seam exception interceptor kicked in, even if I changed my catch to "Throwable". That is, I was single stepping through the code, and once I threw the null pointer with "user.toString()", it went straight to your interceptor! This is really difficult to believe View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3971598#3971598 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971598 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Exception Handling (w/ interceptor)
I did get this working, but I had to back out the Seam jars from CVS, as I couldn't figure out how to avoid hitting the Seam "ExceptionInterceptor". I'm sure there's a simple way to define my interceptor to occur just before that one, but at the moment I'm content with Seam 1.0.1. One question - how did the Seam ExceptionInterceptor class bypass my "catch" clause? In the "save()" method that I included above, the catch clause was never reached if I used the 9/10/2006 CVS jars. Instead, the Seam exception interceptor kicked in, even if I changed my catch to "Throwable". That is, I was single stepping through the code, and once I threw the null pointer with "user.toString()", it went straight to your interceptor! View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3971565#3971565 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971565 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Exception Handling (w/ interceptor)
Oops - stepped in it again! Thanks for your patience. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3971549#3971549 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971549 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Exception Handling (w/ interceptor)
em.getTransaction() is NOT the right way to get access to the JTA transaction (it should be throwing an exception). instead you need to call EJBContext.setRollbackOnly(). You can get the EJBContext from JNDI or by injecting it using @Resource. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3971494#3971494 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971494 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Exception Handling (w/ interceptor)
I tried the following and my transaction is still not rolling back! (Notice I'm purposefully generating a null pointer exception in my save so I can test this.) Also note that, as described above, the EJBException that I'm throwing is being handled in my interceptor which is not rethrowing it. | @Name("viewUser") | @Stateful | @Conversational | public class ViewUserAction implements ViewUser { | | @In(required = false) | @Out(required = false) | private User editUser; | | @PersistenceContext(type = PersistenceContextType.EXTENDED) | private EntityManager em; | |(other attributes and methods removed...) | | public String save() { | try { | if (editUser.getId() == 0) { | em.persist(editUser); | } | | // throw an exception | String user = null; | user.toString(); | } | catch (Exception e) { | try { | em.getTransaction().setRollbackOnly(); | } | catch (Exception xe) {} | | throw new EJBException(e); | } | | return "edituser"; | } | | } | | View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3971436#3971436 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971436 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user
[jboss-user] [JBoss Seam] - Re: Exception Handling (w/ interceptor)
Just call setRollbackOnly(). This is a perfectly reasonable pattern, Seam 1.1's built-in exception handling does much the same thing. View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3971414#3971414 Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3971414 ___ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user