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:
@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(); ...
public Type processRequest(Type request) throws Exception { try { return processRequest2((Request)request); } catch (Exception e) { return new Type(e); //throw e; } }