Results 1 to 4 of 4

Thread: @Aspect doesn't work for me. error at ::0 formal unbound in pointcut

  1. #1
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default @Aspect doesn't work for me. error at ::0 formal unbound in pointcut

    I'm trying to get my head around the new <aop:...> stuff.

    One approach I've done works, and another which I believe should be equivalent does NOT work. Does anyone know what i'm doing wrong? I think i'm missing something fundamental here.

    Using Spring 2.0 final.

    This works, in that specified method calls have logging information printed before the call.

    Code:
    (spring config)
    
    <aop:aspectj-autoproxy/>
    
    <bean id="logger" class="com.myco.tx.SimpleLogger"/>
    
    <aop:config>
      <aop:aspect id="loggingAspect" ref="logger">
        <aop:before 
          pointcut="execution(* com.myco.tx.SomeObject.doAnother*(com.myco.tx.MyData)) and args(myData)"
          method="logMessage" 
          arg-names="myData"/>
      </aop:aspect>
    </aop:config>
    
    ...
    
    (java class)
    public void logMessage(MyData myData) {
      log.debug(myData.getStr() + " **********************");
    }
    The above works in that I get the log.debug message printed out when the com.myco.tx.SomeObject.doAnother method is called.

    Now, if I create a LoggingAspect class (see end of post), and then replace this pointcut expression

    Code:
    execution(* com.myco.tx.SomeObject.doAnother*(com.myco.tx.MyData)) and args(myData)
    with this replacemnt pointcut expression:

    Code:
    com.myco.tx.LoggingAspect.logged()
    then I get an error at ::0 formal unbound in pointcut startup error.

    Code:
    @Aspect
    public class LoggingAspect {
    
      private Log log = LogFactory.getLog(LoggingAspect.class);
    
      @Pointcut("execution(* com.myco.tx.SomeObject.doAnother*(com.myco.tx.MyData)) and args(myData)")
        public void logged() {
    
      }
    }
    Note that the experssion in the @Pointcut annotation above is a copy/paste of the expression in the first <aop:config> based example.


    See http://static.springframework.org/sp...rence/aop.html, section 6.2.3.3 Sharing common pointcut definitions.
    Last edited by gmatthews; Oct 12th, 2006 at 11:12 PM.

  2. #2
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    Your logged() method should declare to take one parameter of type MyData.

    Code:
    public void logged(MyData myData) {
    }
    -Ramnivas
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

  3. #3
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default

    Thanks. That works now.

    I think I realised what I wasn't getting, and this can possibly be added to the AOP doco for others.

    The thing is, its not really that clear (at least to me) which bits of the AOP stuff belong together.

    You can do.

    1. The Spring 1.2.x approach(es)

    2. <aop:aspectj-autoproxy/> + @Aspect annotated classes + make sure you register the @Aspect annotated class with Spring

    3. <aop:config> + non-annotated Spring beans.

    It would probably be good if the Spring doco more clearly pointed out which bits of AOP, i.e. configuration wise, belong together, and maybe a Hello World AOP example multiple ways.

  4. #4
    Join Date
    Apr 2011
    Posts
    1

    Unhappy @Aspect doesn't work for me. error at ::0 formal unbound in pointcut

    I'm trying to use AOP in my application. I tried to use the first approach mentioned by gmatthews i.e

    (spring config)

    <aop:aspectj-autoproxy/>

    <bean id="logger" class="com.xxx.xxx.ws.utility.aop.WSUserAccessLogA spect"/>

    <aop:config>
    <aop:aspect id="loggingAspect" ref="logger">
    <aop:before
    pointcut="execution(* com.xxx.xxx.service.someObject.someMethod*(com.xxx .itservices.schema.xxx.QueryRequestType))and args(queryRequest)"
    method="dataAccessOperation"
    arg-names="queryRequest"/>
    </aop:aspect>
    </aop:config>


    ...

    (java class)
    public void dataAccessOperation(QueryRequestType queryRequest) {
    log.debug(" **********************");
    }

    But I'm getting ::0 formal unbound in pointcut startup error.


    Here's the error log:
    Code:
    <Apr 11, 2011 9:12:41 PM GMT+05:30> <Warning> <HTTP> <BEA-101162> <User defined listener org.springframework.web.context.ContextLoaderListener failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logger' defined in class path resource [spring/applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut .
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'logger' defined in class path resource [spring/applicationContext.xml]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:452)
            at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
            at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
            at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
            at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
            Truncated. see log file for complete stacktrace
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
            at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:286)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
            Truncated. see log file for complete stacktrace
    org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nested exception is java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
            at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
            at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:105)
            at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:278)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993)
            at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897)
            Truncated. see log file for complete stacktrace
    java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
            at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:317)
            at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:204)
            at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:191)
            at org.springframework.aop.aspectj.AspectJExpressionPointcut.getMethodMatcher(AspectJExpressionPointcut.java:177)
            at org.springframework.aop.aspectj.AbstractAspectJAdvice.buildSafePointcut(AbstractAspectJAdvice.java:188)
            Truncated. see log file for complete stacktrace
    >
    <Apr 11, 2011 9:12:41 PM GMT+05:30> <Error> <Deployer> <BEA-149265> <Failure occurred in the execution of deployment request with ID '1302536553299' for task '1'. Error is: 'weblogic.application.ModuleException: '
    weblogic.application.ModuleException:
            at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1373)
            at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:468)
            at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
            at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
            at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
            Truncated. see log file for complete stacktrace
    java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
            at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:317)
            at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:204)
            at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:191)
            at org.springframework.aop.aspectj.AspectJExpressionPointcut.getMethodMatcher(AspectJExpressionPointcut.java:177)
            at org.springframework.aop.aspectj.AbstractAspectJAdvice.buildSafePointcut(AbstractAspectJAdvice.java:188)
            Truncated. see log file for complete stacktrace
    >
    <Apr 11, 2011 9:12:41 PM GMT+05:30> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 1 task for the application 'xxx-wss-3'.>
    <Apr 11, 2011 9:12:41 PM GMT+05:30> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'xxx-wss-3'.>
    <Apr 11, 2011 9:12:41 PM GMT+05:30> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
    weblogic.application.ModuleException:
            at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1373)
            at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:468)
            at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:204)
            at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
            at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:60)
            Truncated. see log file for complete stacktrace
    java.lang.IllegalArgumentException: error at ::0 formal unbound in pointcut
            at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:317)
            at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:204)
            at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:191)
            at org.springframework.aop.aspectj.AspectJExpressionPointcut.getMethodMatcher(AspectJExpressionPointcut.java:177)
            at org.springframework.aop.aspectj.AbstractAspectJAdvice.buildSafePointcut(AbstractAspectJAdvice.java:188)
            Truncated. see log file for complete stacktrace
    Last edited by rahulaj; Apr 12th, 2011 at 05:00 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •