Results 1 to 4 of 4

Thread: Pointcut yields: Pointcut is not well-formatted exception

  1. #1
    Join Date
    Nov 2008
    Posts
    7

    Default Pointcut yields: Pointcut is not well-formatted exception

    Hi,

    For some control with regards to licensing in our product I'm looking into a point-cut which is only targeted at the services exposed.

    The application context looks as follows:

    Code:
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:aop="http://www.springframework.org/schema/aop"
      xsi:schemaLocation=
           "http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/security 
            http://www.springframework.org/schema/security/spring-security-3.0.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> 
    
    ...
    
        <!-- A service interceptor that intercepts other services with methods annotated with @Profile -->
        <beans:bean id="methodTimeProfiler" class="com.mot.dm.server.MethodProfiler"/>
    
        <aop:config>
            <aop:aspect ref="methodTimeProfiler">
                <aop:pointcut id="profiledMethods" expression="exeuction(public Agency com.mot.dm.common.service.AgencyService.addAgency(..))" />
                <aop:around pointcut-ref="profiledMethods" method="profileMethod"/>
            </aop:aspect>
        </aop:config>
    I've been trying different setup of the execution part

    Code:
    exeuction(public Agency com.mot.dm.common.service.AgencyService.addAgency(..))
    But regardless of what I do I always end up with the following message - or similar:

    Code:
    Exception: Error creating bean with name 'org.springframework.aop.aspectj.Aspect
    JPointcutAdvisor#0': Instantiation of bean failed; nested exception is org.sprin
    gframework.beans.BeanInstantiationException: Could not instantiate bean class [o
    rg.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw except
    ion; nested exception is java.lang.IllegalArgumentException: Pointcut is not wel
    l-formed: expecting ')' at character position 17
    exeuction(public Agency com.mot.dm.common.service.AgencyService.addAgency(..))
    And by now I have no idea what is causing this issue, as it seems that the syntax is as stated here: http://static.springsource.org/sprin...#aop-pointcuts section 6.2.3.4.

    Any ideas will be most appreciated.

    Thanx & Regards
    Jens

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    For starters it is execution not exeuction, next to that try specifying the fully qualified classname of the return type else it will not match.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Nov 2008
    Posts
    7

    Default

    Quote Originally Posted by Marten Deinum View Post
    For starters it is execution not exeuction, next to that try specifying the fully qualified classname of the return type else it will not match.
    Hi Marten

    Correct - stupid mistake

    I fixed the spelling mistake and add the fully qualified classname for the return type, but then I get the following:

    Code:
    Bean with name 'aclService' has been injected into ot
    her beans [accessControlManager] in its raw version as part of a circular refere
    nce, but has eventually been wrapped. This means that said other beans do not us
    e the final version of the bean. This is often the result of over-eager type mat
    ching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turne
    d off, for example.
    I've been trying to find documentation about how thi "allowEagerInit" is set, but so far no luck - any ideas.

    Regards
    Jens

  4. #4
    Join Date
    Nov 2008
    Posts
    7

    Default

    Hi again

    A slight change in the implementation - instead of declaring the aspect in the xml, I've done it in the source code itself. So this is the source for the aspect:

    Code:
    package com.mot.dm.server;
    
    import org.apache.log4j.Logger;
    import org.aspectj.lang.ProceedingJoinPoint;
    import org.aspectj.lang.annotation.Aspect;
    import org.aspectj.lang.annotation.Pointcut;
    
    @Aspect
    public class MethodProfiler {
     
        protected final Logger logger = Logger.getLogger("com.mot.dm");
     
        @Pointcut("execution(* com.mot.dm.common.service.AgencyService.addAgency(..))")
        public void profileMethod(ProceedingJoinPoint pjp) throws Throwable {
    			logger.info("In profileMethod");
        }
    }
    The snippet from the application context:

    Code:
        <!-- Enabeling the aspect support -->
        <bean class="org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator" />
        
        <!-- The aspect source -->
        <bean id="methodTimeProfiler" class="com.mot.dm.server.MethodProfiler"/>
    Sadly enough this setup yields exactly the same exception as the other approach:

    Code:
    Error creating bean with name 'permissionEvaluator' defined in
    ServletContext resource [/WEB-INF/dms-security.xml]: Cannot resolve reference to
     bean 'aclService' while setting constructor argument; nested exception is org.s
    pringframework.beans.factory.BeanCurrentlyInCreationException: Error creating be
    an with name 'aclService': Bean with name 'aclService' has been injected into ot
    her beans [accessControlManager] in its raw version as part of a circular refere
    nce, but has eventually been wrapped. This means that said other beans do not us
    e the final version of the bean. This is often the result of over-eager type mat
    ching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turne
    d off, for example.
    This actually puzzles me a little, because I've setup the aspect to only apply to "com.mot.dm.common.service.AgencyService.addAgency (..)", but still Spring tries to apply the aspect to the AclService class, which is in a complete different package - in other words the pointcut setup only comes into play during run-time and not during start-up (which I had hoped).

    Any way I can restrict Spring in setting up the aspect on only the beans I need?

    Thanx
    Jens

Posting Permissions

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