Hi at all,
(sorry for the crosspost)
I have a problem, I have an EJB which has an entry method that is called by the
container. I dont want this method to throw an exception, so I put the business
code in another method in the same bean:
|
| @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
| public Response processRequest2(Request request) throws Exception
| {
| checkPolicy(request);
|
| checkExtensions(request);
|
| // initialize the info object
| Info info = new Info(request);
|
| // set serial number
| SerialNumber sn = em.find(SerialNumber.class,
Long.valueOf(0));
| if (sn == null)
| {
| sn = new SerialNumber(0);
| em.persist(sn);
| logger.log(AdLevel.INFO, "Serial number not
found, creating entity");
| }
| BigInteger serial = sn.getSerial();
|
| serial.toString());
| info.setSerialNumber(serial);
| sn.setSerial(serial.add(BigInteger.ONE));
|
| if (true)
| throw new CryptoProcessorException();
|
|
| ...
|
|
This method does not catch the CryptoProcessorException which is annotated with
the rollback=true property.
The calling method looks like this:
|
| public Type processRequest(Type request) throws Exception
| {
| try
| {
| return processRequest2((Request)request);
| }
| catch (Exception e)
| {
| return new Type(e);
| //throw e;
| }
| }
|
In this case, the serial number is always increased!!!
I'm a bit confused.
But if I rethrow the Exception, the rollback works.
Isnt there a possibility to catch the exception in the processRequest method
and to get the rollback working?
Thanks
Thomas
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3976253#3976253
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3976253
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user