Description of problem: Exception handling in the IDM DAO layer is inconsistent/incomplete: * GTNPORTAL-2928: Exceptions are swallowed completely * GTNPORTAL-3110: Exception handling is inconsistent How reproducible: Always Steps to Reproduce: 1. IDM operation fails with an error (eg. Hibernate exception, database exception) in, for example, UserDAOImpl.authenticate(..) method when the lastLoginTime attribute is saved for the user 2. An exception is thrown: ERROR [org.exoplatform.services.organization.idm.PicketLinkIDMOrganizationServiceImpl] ORA-00001: unique constraint (PORTAL_IDM_OWNER.JBID_IO_ATTR_TEXT_VALUES_PK) violated : org.hibernate.exception.ConstraintViolationException: ORA-00001: unique constraint (PORTAL_IDM_OWNER.JBID_IO_ATTR_TEXT_VALUES_PK) violated ... at org.exoplatform.services.organization.auth.OrganizationAuthenticatorImpl.validateUser(OrganizationAuthenticatorImpl.java:152) [exo.core.component.organization.api-2.5.1-CP01-redhat-1.jar:2.5.1-CP01-redhat-1] Caused by: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (PORTAL_IDM_OWNER.JBID_IO_ATTR_TEXT_VALUES_PK) violated 3. Every IDM operation that happens afterwards on the same thread is failing: INFO [org.exoplatform.services.organization.idm.UserDAOImpl] Cannot obtain user: user1; : org.picketlink.idm.common.exception.IdentityException: Cannot obtain Hibernate Session ... Caused by: org.hibernate.TransactionException: nested transactions not supported at org.hibernate.engine.transaction.spi.AbstractTransactionImpl.begin(AbstractTransactionImpl.java:152) [hibernate-core-4.1.6.Final-redhat-3.jar:4.1.6.Final-redhat-3] at org.picketlink.idm.impl.store.hibernate.HibernateIdentityStoreSessionImpl.startHibernateTransaction(HibernateIdentityStoreSessionImpl.java:207) [picketlink-idm-hibernate-1.4.1.Final-redhat-1.jar:1.4.1.Final-redhat-1] at org.picketlink.idm.impl.store.hibernate.HibernateIdentityStoreSessionImpl.startHibernateTransactionIfNotStartedYet(HibernateIdentityStoreSessionImpl.java:195) [picketlink-idm-hibernate-1.4.1.Final-redhat-1.jar:1.4.1.Final-redhat-1] at org.picketlink.idm.impl.store.hibernate.HibernateIdentityStoreImpl.getHibernateSession(HibernateIdentityStoreImpl.java:2786) [picketlink-idm-hibernate-1.4.1.Final-redhat-1.jar:1.4.1.Final-redhat-1] Actual results: Exception is not handled correctly, causing the transaction status captured in HibernateIdentityStoreSessionImpl.hibernateTxStatus ThreadLocal to be wrong, which affects all subsequent operations on the same thread. Expected results: Exception is handled correctly, not affecting further IDM operations on the same thread. Additional info:
Verified in 6.1.0.ER02.