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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:02:41+00:00 2026-05-23T18:02:41+00:00

I’m trying to trace execution of an app running on ServiceMix 3.2 which uses

  • 0

I’m trying to trace execution of an app running on ServiceMix 3.2 which uses spring 2.5 under the hood. I’m using CGLIB (advising classes, not interfaces) and I would like to direct tracing using pointcuts. I therefore configured spring to perform load-time weaving in one of my service unit xbean.xml files like so:

<bean id="debugInterceptor"
    class="org.springframework.aop.interceptor.SimpleTraceInterceptor"/>
<aop:config proxy-target-class="true">
    <aop:advisor advice-ref="debugInterceptor"
        pointcut="within(my.package.AClass)" order="1"/>
</aop:config>

Classes get advised, but it isn’t limited to what I specified in the pointcut, i.e. methods of classes other than my.package.AClass get advised and, for reasons not important here, break class loading.

I tried defining the pointcut this way, but it made no difference:

<aop:advisor advice-ref="debugInterceptor"
    pointcut="execution(* my.package.AClass.*(..))" order="1"/>

In general, I would like to advise my.package..* classes except my.package.no_aop.*, but I don’t seem to be making progress.

Why does CGLIB process classes outside of my.package.AClass? How do I prevent it? Would switching to Spring AOP (as opposed to AspectJ) make a difference?

  • 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-23T18:02:41+00:00Added an answer on May 23, 2026 at 6:02 pm

    I did it using Spring 3.0.x and @AspectJ annotations, but it should be analogous using 2.5 and XML.

    Class A from package my.pkg, that needs to be adviced:

    package my.pkg;
    
    public class ClassA {
    
        public void doFromClassA() {
            System.out.println("Hello from A!");
        }
    }
    

    Class B from package my.pkg.noaop, that needs not to be adviced:

    package my.pkg.noaop;
    
    public class ClassB {
    
        public void doFromClassB() {
            System.out.println("Hello from B!");
        }
    }
    

    The aspect:

    import org.aspectj.lang.ProceedingJoinPoint;
    import org.aspectj.lang.annotation.Around;
    import org.aspectj.lang.annotation.Aspect;
    
    @Aspect
    public class AopTestAspect {
    
        @Around("within(my.pkg..*) && !within(my.pkg.noaop..*)")
        public void advice(ProceedingJoinPoint pjp) throws Throwable {
            System.out.println("Hello from adviced!");
            pjp.proceed();
        }
    }
    

    The configuration (let me know if You need XML version):

    import my.pkg.ClassA;
    import my.pkg.noaop.ClassB;
    
    import org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;
    import org.springframework.context.annotation.Bean;
    import org.springframework.context.annotation.Configuration;
    
    @Configuration
    public class AopTestConfig {
    
        @Bean
        public ClassA classA() {
            return new ClassA();
        }
    
        @Bean
        public ClassB classB() {
            return new ClassB();
        }
    
        @Bean
        public AopTestAspect aspect() {
            return new AopTestAspect();
        }
    
        @Bean
        public AnnotationAwareAspectJAutoProxyCreator autoProxyCreator() {
            AnnotationAwareAspectJAutoProxyCreator autoProxyCreator = new AnnotationAwareAspectJAutoProxyCreator();
            autoProxyCreator.setProxyTargetClass(true);
            return autoProxyCreator;
        }
    }
    

    The test:

    import my.pkg.ClassA;
    import my.pkg.noaop.ClassB;
    
    import org.junit.Test;
    import org.springframework.beans.factory.BeanFactoryUtils;
    import org.springframework.context.annotation.AnnotationConfigApplicationContext;
    
    public class AopTest {
    
        @Test
        public void test() {
            AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
            applicationContext.register(AopTestConfig.class);
            applicationContext.refresh();
    
            ClassA a = BeanFactoryUtils.beanOfType(applicationContext, ClassA.class);
            ClassB b = BeanFactoryUtils.beanOfType(applicationContext, ClassB.class);
    
            a.doFromClassA();
            b.doFromClassB();
        }
    }
    

    And the output from the test:

    Hello from adviced!
    Hello from A!
    Hello from B!
    

    As You can see only the ClassA got adviced.

    Conclusion

    The key is the pointcut experssion:

    within(my.pkg..*) && !within(my.pkg.noaop..*)

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
We're building an app, our first using Rails 3, and we're having to build
I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am using Paperclip to handle profile photo uploads in my app. They upload
I am writing an app for my school newspaper, which is run completely online
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.