Announcement Announcement Module
Collapse
No announcement yet.
bean() not finding beanId; failing to accept wildcard Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • bean() not finding beanId; failing to accept wildcard

    I am trying to introduce a pointcut for a specific bean instance:

    Code:
    @Aspect
    @Order(90) //must be of higher priority (execute around) transactionIntercepter-driving Advisor
    @Component("txRetryAspect")
    public class TxRetryAspect {
    
    @Pointcut("bean(DgTxTemplate)")
        public void txTemplate() {
        }
    
    ...
    }


    Where bean in question is defined like so:
    Code:
        <bean id="DgTxTemplate" class="com.doppelganger.service.tx.DgTxTemplateImpl">
            <property name="transactionManager" ref="transactionManager"/>
        </bean>


    And implements an interface:

    Code:
    public interface DgTxTemplate extends TransactionOperations {
    }


    When the app starts up I get:

    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'btmConfig' defined in class path resource [spring-data.xml]:
    .
    .
    .
    Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut bean
    at org.aspectj.weaver.tools.PointcutParser.parsePoint cutExpression(PointcutParser.java:315)
    at org.springframework.aop.aspectj.AspectJExpressionP ointcut.buildPointcutExpression(AspectJExpressionP ointcut.java:206)
    at org.springframework.aop.aspectj.AspectJExpressionP ointcut.checkReadyToMatch(AspectJExpressionPointcu t.java:193)


    Why is bean unrelated to DgTxTemplate failing to init? But, more curiously, why "can't find referenced pointcut bean"?

    So then I tried using a wildcard in Pointcut def:

    Code:
        @Pointcut("bean(*xTemplate)")
        public void txTemplate() {
        }
    
    And got this:
    java.lang.IllegalArgumentException: error wildcard type pattern not allowed, must use type name
    at org.aspectj.weaver.tools.PointcutParser.parsePoint cutExpression(PointcutParser.java:315)
    at org.springframework.aop.aspectj.AspectJExpressionP ointcut.buildPointcutExpression(AspectJExpressionP ointcut.java:206)
    at org.springframework.aop.aspectj.AspectJExpressionP ointcut.checkReadyToMatch(AspectJExpressionPointcu t.java:193)
    Why? Spring AOP reference says wildcards are allowed:

    Spring AOP also supports an additional PCD named 'bean'. This PCD allows you to limit the matching of join points to a particular named Spring bean, or to a set of named Spring beans (when using wildcards).
    I am using Spring 2.5.6.

    Thanks!
    -nikita

  • #2
    I remember seeing this (or a similar) bug. I think you have an older version of AspectJ on the classpath (which has the no wildcard in bean() pointcut bug).

    -Ramnivas

    Comment

    Working...
    X