Announcement Announcement Module
Collapse
No announcement yet.
@AfterThrowing not Working with JTA Global Transaction Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @AfterThrowing not Working with JTA Global Transaction

    Hi all,
    I am using JTA transaction management to achieve global transaction support in my project. I am using Aspectj to log the error message to my log file. Every thing is working fine if I am not using any transaction. But, in case of transaction it is not calling/going inside the @AfterThrowing method.

    Code:
    @AfterThrowing(pointcut = "businessService() || dataAccessOperation()", throwing = "throwable", argNames = "joinPoint, throwable")
    	public void afterExceptions(JoinPoint joinPoint, Throwable throwable) {
    	logger.error(throwable.getMessage(), throwable.getCause());
    }
    
    Service Layer Class method:
    
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
    	@Override
    	public boolean saveDetails(final TSOEmployee tsoEmp, final IqScopeSync iqScop) throws BOException {
    		// TODO Auto-generated method stub
    		try {
    			welcomeDao.saveTsoEmployee(tsoEmp);
    			welcomeDao.saveIqScopeSync(iqScop);
    		} catch (DAOException e) {
    			// TODO: handle exception
    			throw new BOException(e.getMessage(), e.getCause());
    		}
    		return true;
    }
    
    DAO Class method:
    
    @Override
    	public void saveTsoEmployee(TSOEmployee tsoEmp) throws DAOException {
    		// TODO Auto-generated method stub
    		try {
    			getHibernateTemplateCu().save(tsoEmp);
    			//throw new DAOException("TESTING LOG PRINT");
    		} catch (RuntimeException e) {
    			// TODO: handle exception
    			throw new DAOException(e.getMessage(), e.getCause());
    		}
    	}
    
    	@Override
    	public void saveIqScopeSync(IqScopeSync iqScop) throws DAOException {
    		// TODO Auto-generated method stub
    		try {
    			getHibernateTemplateGodb().save(iqScop);
    		} catch (RuntimeException e) {
    			// TODO: handle exception
    			throw new DAOException(e.getMessage(), e.getCause());
    		}
    	}
    If I am using @Transaction to save the data, the exception thrown at DAO/BO is not going to Catch block.
    The @Before and @After advice is working fine.

    Please suggest whether I am doing any mistake or give me some solutions to log the error message.
Working...
X