0 Replies Latest reply on Oct 4, 2006 6:46 PM by Thomas ABBE

    Transaction & Method calls

    Thomas ABBE Newbie

      Hi at all,

      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:

       public Response processRequest2(Request request) throws Exception
       // 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);
       logger.log(AdLevel.INFO, "Serial number not found, creating entity");
       BigInteger serial = sn.getSerial();
       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
       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?