Announcement Announcement Module
No announcement yet.
AfterThrowing aspect not called? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • AfterThrowing aspect not called?

    I am just starting with spring aop so please bear with me.
    And i cant really figure out whats going on
    This is what I have -
    public class BatchingAspect implements ThrowsAdvice{
    	private transient Log log = LogFactory.getLog(BatchingAspect.class){
    	public void afterThrowing(Exception ex) {
    		log.error("i am inside afterThrowing of BatchingAspect");
                    System.out.println("i am inside afterThrowing of BatchingAspect");
    public class AtomAnteDaoHibernate extends HibernateBaseDao<AtomAnte> implements AtomAnteDao {
    	private transient Log log = LogFactory.getLog(AtomAnteDaoHibernate.class);
    	public List<AtomAnte> loadAntes(List<Long> atoms)
    			throws ObjectNotFoundException {
    		if(true) {
    			log.debug("throwing UncategorizedSQLException");
    			throw new UncategorizedSQLException("myTask","select * from t",
    new SQLException("Too many ANDs or ORs in expression (limit 1024 per expression level). 
    Try splitting query or limiting ANDs and ORs.","ZZZZZ",404));
    and my spring config - 
    <bean id="batchingAspect"
            class="BatchingAspect" />
        <aop:pointcut id="getListMethod" expression="execution(* AtomAnteDaoHibernate.loadAntes(..))"/> 
        <aop:advisor advice-ref="batchingAspect" pointcut-ref="getListMethod" />
    And i can see inside the debug logs --
    19:41:16,589 DEBUG [org.springframework.aop.framework.adapter.ThrowsAd viceInterceptor] Found exception handler method: public void BatchingAspect.afterThrowing(java.lang.Exception)
    19:41:16,591 DEBUG [AtomAnteDaoHibernate] throwing UncategorizedSQLException

    I dont know what i am doing wrong, my aspect is not called.
    the same thing works outside of jboss(or atleast simliar configuration).

  • #2
    AfterThrowing aspect not called?

    Any ideas on what i could be doing wrong here ?
    Is it just configuration ?
    Could somebody point me in the right direction ?

    help would be greatly appreciated.


    • #3
      I think your pointcut is wrong. You need to include the package name (or a wildcard for the package). No it will only match classes in the default/root package.

      Also check your log levels, it might be that you don't see your logging due to logging configuration.