java - Why session bean method throw EjbTransactionRolledbackException when RuntimeException was thrown -
I am trying to continue with the unit stability, when it continues - the obstacle that is thrown and collars To ezbetin rollback exception
... so I try to clarify the recognition and call the constraintiolationException
/ runtime exposure
and still caller To get the EjbTransactionRolledbackException
. When I MyException
extends exception
- caller to get myException
even when I call clear
This should not be done.
What's going on?
Configuration: < / P>
Netbeans 6.9.1 Glassfish 3.0.1 JPA 2.0 (Eclipse Link) EJB 3.1
Thanks!
@Stateless Public Class Me {@ Precision Contact Entity Manager; @ Resource Validator Verifier; Summary Public order checkout (order order) {set & lt; restriction violation & lt; order & gt; & gt; Set = validator.validate (order, Default.class); if (! Set.isEmpty ()) {sc. SetRollbackOnly (); // new violation infringement violation (new hashasset & lt; violation violation & lt ;? & gt; & gt;; set); throw new runtime exception;} this.em.persist (order); }
So I try to call clarity and ConstraintViolationException / I try to throw RuntimeException and now Also get collar EjbTransactionRolledbackException ...
Anything can be done to provide complete stacktrace, I wonder how you are calling your EJB and if you have a transaction In the case of an EJB transaction rollback throwing exception, the system is the right behavior in case of exception, but the following blog posts can be helpful:
JPA Sons within EJB3 Bean If you use Bean Verification on the basis then you will actually get an EJB transaction rollback exception if there is a compulsion infringement
javax.ejb.EJBTransactionRolledbackException: Invalid item on a timely basis for groups [javax .validation.groups.Default,] By: javax.validation.ConstraintViolationException: Invalid object on continuous time for groups [Javax.validation.groups.Default,]
This is all good According to the specification, but really interesting to know Respect is not what you really want to know what happened, you want to know what's wrong happened.
So I recommend adding the following to my ebb-jar XML:
& lt ;? XML version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Ejb-jar xmlns = "http://java.sun.com/xml/ns/javaee" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" XSI: Schema Location = "Http : //java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd "version =" 3.0 "& gt; & Lt; Assembly-descriptor & gt; & Lt; Application-exception & gt; & Lt; Exception category & gt; Javax.validation.ConstraintViolationException & lt; / Exception category & gt; & Lt; Rollback & gt; True & lt; / Rollback & gt; & Lt; / Application-exception & gt; & Lt; / Assembly-descriptor & gt; & Lt; / EJB-Jar & gt;
In this way you can directly access your violations.
Resource
- On EJB and application versus system exception:
-
-
-
-
on Bean Validation
Comments
Post a Comment