Note that there are some explanatory texts on larger screens.

plurals
  1. POExceptions not handled in JPA
    text
    copied!<p>We developed the stateless Web-service implementation. We used JPA as ORM layer to do the database operations. In service methods, we used the Entity Manager to persist the entity. while persisting the same record into the table, we are not able to handle those exception "Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (TIGOSUSCRIPTIONES.SYS_C0020549) violated" exception in Service method. It is directly throwing the following exception in client result.</p> <pre><code> Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Transaction rolled back at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178) at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:111) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:108) at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:78) at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:107) at $Proxy30.registerSaleOutcome(Unknown Source) How can I handle this exception? Following is the code we used in service method business logic. @TransactionAttribute(TransactionAttributeType.REQUIRED) public void recycleOperation(Recycle recycle) throws RecycleFault_Exception{ try { em.persist(recycle); } catch(Exception e){ // not coming to this block log.error("Exception in Data Insertion:"+e.getMessage()); RecycleFault fault = new RecycleFault(); fault.setErrorCode("101"); fault.setMessage("Record is already Existed"); RecycleFault_Exception faultExp = new RecycleFault_Exception("RecycleFault Exception", fault); throw faultExp; } } </code></pre> <p>Could you help me to solve this problem.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload