Search code examples
javaspringaspect

Spring aspect not working with identical configuration in similar project


I have 2 war project similar project which have common configuration:

<?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:util="http://www.springframework.org/schema/util" xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">

    <aop:aspectj-autoproxy proxy-target-class="true" />

    <bean class="config.store.PersistentAspect">
    </bean>

aspect method is:

@AfterReturning("@annotation(org.springframework.jmx.export.annotation.ManagedOperation) && !execution(* get*(..)) && !execution(* is*(..)) && !execution(* reset())")
public void do(JoinPoint jp) {
}

When I see application log aspect is initialized in both project. Problem is that aspect works just in one project and in second no.

When I turn of logging org.springframework I can see, in project where it works, this line:

01:59:31.299 [RMI TCP Connection(4)-127.0.0.1] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Returning cached instance of singleton bean 'config.store.PersistentAspect#0'

In second no. How should I debug it and find why it is no working? What can stop working this aspect? Another aspect?


Solution

  • ok

    when I turn on logging on whole spring I found this:

    Bean 'myClass' of type [class MyClass] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
    

    I just wonder why it is not at least warning but just debug info. And is this solution still suitable in multithreading application like web services ?