Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6668845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:05:06+00:00 2026-05-26T03:05:06+00:00

I am struggling to write/configure a ThrowsAdvice interceptor that I want to intercept all

  • 0

I am struggling to write/configure a ThrowsAdvice interceptor that I want to intercept all exceptions thrown throughout my project:

public class ExceptionsInterceptor implements ThrowsAdvice
{
    public void afterThrowing(final Method p_oMethod, final Object[] p_oArgArray,
        final Object p_oTarget, final Exception p_oException)
    {
        System.out.println("Exception caught by Spring AOP!");
    }
}

I have already successfully configured a MethodInterceptor implementation that intercepts particular methods that I want to profile (see how long it takes them to execute). Here is the XML config file I have so far:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"/>

<bean name="profilingInterceptor" class="org.me.myproject.aop.ProfilingInterceptor"/>

<bean name="exceptionsInterceptor" class="org.me.myproject.aop.ExceptionsInterceptor"/>

<aop:config>
    <aop:advisor advice-ref="profilingInterceptor" pointcut="execution(* org.me.myproject.core.Main.doSomething(..))"/>
</aop:config>

My ProfilingInterceptor works perfectly and intercepts precisely when my Main::doSomething() method gets invoked – so I known I’m ontrack. Using XmlSpy to look at Spring AOP’s schema, it looks like I can add something like the following in order to get my ExceptionsInterceptor to intercept all thrown exceptions:

<aop:aspect>
    <after-throwing method=""/>
</aop:aspect>

However I cannot find any documentation where this is used as an example, and I have no idea how to configure the method attribute so that its a “wildcard” (*) and matches all classes and all methods.

Can anyone point me in the right direction? Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:05:06+00:00Added an answer on May 26, 2026 at 3:05 am

    According to aspectJ examples method parameter refers to @AfterThrowing advice method:

    @Aspect
    public class LoggingAspect {
    
      @AfterThrowing(
       pointcut = "execution(* package.addCustomerThrowException(..))",
       throwing= "error")
      public void logAfterThrowing(JoinPoint joinPoint, Throwable error) {
        //...
      }
    }    
    

    and then the configuration:

     <aop:after-throwing method="logAfterThrowing" throwing="error"   />
    

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm struggling to write a Windows Service that accesses a website, logs in using
I'm struggling to write Makefiles that properly build my unit tests. As an example,
I've been struggling all day with the document.write and the onLoad function. If you
I am struggling to write a query based on the table below that should
I'm struggling to write a test that confirms that I am correctly unsubscribing from
I'm struggling to write a reg-ex that can do the following: Label1.Caption := Edit1.Text;
I'm struggling to write a regular expression to find all my mp3 files. I
I'm struggling to write a perl-compatible regex that will be reasonably smart about distinguishing
I am struggling to write a query to result in the following records. I
I am struggling to write an AND conditional filter in log4net. Had it been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.