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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:11:29+00:00 2026-05-16T12:11:29+00:00

I am just getting started with Spring AOP in my project and am having

  • 0

I am just getting started with Spring AOP in my project and am having some problems with getting Spring AOP working correctly.

I have two objects, TransportImpl and SesssionImpl that I would like to profile via AOP. Both objects(beans) are initialised via Spring. Both beans are implementations of business
interfaces (Transport and Session). I can get Aspects applied to the TransportImpl bean to work well, but those applied to the SessionImpl just do not fire. I can confirm that the
“mySessionMonitor” Aspect is initialised by Spring, and that the SessionImpl object is also initialised without any exceptions or errors.

I have stripped down my PointCuts and Aspect to the most basic form possible. I would have expected the PointCut sessionOperation described below
to fire when the SessionImpl bean is initialised and the init-method initialise is called. But this never happens. What might be going wrong here?

From the configuration file:

<bean id="MyTransport" class="my.app.transport.TransportImpl"   scope="singleton" />                
<bean id="MySession" class="my.app.session.SessionImpl" init-method="initialise" scope="singleton" />

<aop:aspectj-autoproxy proxy-target-class="true">
    <aop:include name="myTransportMonitor" />
    <aop:include name="mySessionMonitor" />
</aop:aspectj-autoproxy>

<bean id="myTransportMonitor" class="my.app.aspects.TransportMonitoringAspect"/>
<bean id="mySessionMonitor"   class="my.app.aspects.SessionMonitoringAspect" />

Aspect code

// Aspect monitoring code
@Aspect
public class SessionMonitoringAspect
{
    private Logger fileLogger = Logger.getLogger("myLogger");

    public void initialise()
    {
        fileLogger.info("Initialising SessionMonitoringAspect");
    }

    @Pointcut ("execution (public * *(..))")
    private void anyPublicOperation(){}

    @Pointcut ("within(my.app.session..*)")
    private void inSession(){}

    @Pointcut("anyPublicOperation() && inSession()")
    private void sessionOperation(){}

    @Before("sessionOperation()")
    public void sessionOperationDetected(JoinPoint jp)
    {
        fileLogger.info("Session operation detected - signature: " + jp.getSignature());
    }
}
  • 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-16T12:11:30+00:00Added an answer on May 16, 2026 at 12:11 pm

    I personally prefer to put the Aspect pointcut configuration in the application context, and you are missing the ref in aop:aspect.

     <bean id="mySessionMonitor"   class="my.app.aspects.SessionMonitoringAspect" />
    
     <aop:config proxy-target-class="true">
      <aop:aspect ref="mySessionMonitor">
       <aop:pointcut id="around" expression="execution (public * *(..))"/></aop:pointcut>
       <aop:around pointcut-ref="around" method="aroundAdvice"/>
      </aop:aspect>
     </aop:config>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just getting started with LINQ, and I'm having some troubles. Say I wanted
I'm just getting started with M-V-VM and WPF and having issues understanding some binding
I'm just getting started with grails, and I'm having an issue. I have a
I'm just getting started with android development, and I've ran into some problems my
I just started digging into StructureMap and am running into some problems getting my
Just getting started with C++ here. I am working on OSX with Eclipse CDT.
Just getting started on NVelocity (v1.1.1) and it seems to be working just fine.
I am just getting started couchdb and have been looking into writing couch apps.
I am just getting started with Spring (MVC,Webflow etc etc) and I am trying
Just getting started with jQuery, and I've had some success so far. I've created

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.