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 4082800
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:13:56+00:00 2026-05-20T18:13:56+00:00

I have a Java app that uses Spring, and I have the aspect @Aspect

  • 0

I have a Java app that uses Spring, and I have the aspect

@Aspect
public class MyAspect
{

    @Pointcut("execution (* com.mycompany.MyClass.*(..))")
    public void doStuff() {}

    @Around("doStuff()")
    public Object aroundDoStuff(ProceedingJoinPoint pjp) throws Throwable
    {
        System.out.println("before doStuff);
      try
      {
        return pjp.proceed();
      }
      finally
      {
        System.out.println("after doStuff");
      }
  }
}

Then my spring bean file has

<aop:aspectj-autoproxy proxy-target-class="true" />
<bean id="MyAspect"
    class="com.mycompany.MyAspect" />

Now I would expect that all methods in MyClass get matched by the pointcut above, but that doesn’t seem to be the case (only one of the methods seems to have the advice applied). I’m not sure if this has to do with the fact that I’m proxying a class or not, but does anyone see what I might be doing wrong here?

EDIT: The code is called from a main class that does something like this:

ApplicationContext cxt; // lookup the cxt
MyClass mc = (MyClass) cxt.getBean("MyClassBean");
mc.doSomething(); // I expect the advice to be applied here.

thanks,
Jeff

  • 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-20T18:13:57+00:00Added an answer on May 20, 2026 at 6:13 pm

    It turned out the issue is because I was proxying a class and not an interface. I needed to change the pointcut to match all of the classes that implemented the interface and then used the target pointcut to filter down to MyClass.

    Edit: Adding details…

    If MyClass extends AbstractMyClass and implements MyInterface, I wanted all methods in MyInterface to be advised, but this was not the case. I incorrectly declared my pointcut as:

    @Pointcut(execution(* com.mycompany.MyClass.methodInAbstract()))
    

    Changing it to

    @Pointcut(execution(* com.mycompany.MyInterface.methodInAbstract()) && target(com.mycompany.MyClass))
    

    worked well.

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

Sidebar

Related Questions

I have a flex app that uses AMF to talk to a Spring Java
I have a java app that uses log4j. Config: log4j.rootLogger=info, file log4j.appender.file=org.apache.log4j.DailyRollingFileAppender log4j.appender.file.File=${user.home}/logs/app.log log4j.appender.file.layout=org.apache.log4j.PatternLayout
We have a Spring application that uses Apache DBCP for connection pooling. Our app
I have app engine app that uses a java servlet to save a message
I have an app that uses Spring and is run with Jetty. I was
I have a large Java app that uses massive amounts of memory at times
I have a Java app that can authenticate to LDAP by logging users into
I'm have a Java app that also runs as an applet. The app also
I have a standalone Java app that has some licensing code that I want
I have a large Java app that is split up into multiple projects. Each

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.