Announcement Announcement Module
Collapse
No announcement yet.
Spring AOP pointcut trouble with Axis2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring AOP pointcut trouble with Axis2

    Here is my aop:config:

    Code:
    	<bean id="biwsLogger" class="log.BIWSLogger">
    		<constructor-arg type="java.lang.String">
    			<value>conf/log.properties</value>
    		</constructor-arg>
    	</bean>	
    	
    	<aop:config>
    		<aop:aspect id="loggerAspect" ref="biwsLogger">
    			<aop:pointcut id="getListDetailsPointCut" expression="execution(* ListsSearch.searchListsDetails(..)) and args(hitList)"/>
    			<aop:pointcut id="searchListsPointCut" expression="execution(* ListsSearch.searchListsPerson(..)) and args(name, lists)"/>			
    			<aop:around pointcut-ref="getListDetailsPointCut" method="logGetListDetails"/>
    			<aop:around pointcut-ref="searchListsPointCut" method="logSearchLists"/>			
    		</aop:aspect>
    	</aop:config>
    The biwsLogger methods:

    Code:
    	public Object logGetListDetails(ProceedingJoinPoint proceedingJoinPoint, List<Hit> hitList) throws Throwable
    	{
    		..	
            }
    	
    	public Object logSearchLists(ProceedingJoinPoint proceedingJoinPoint, String name, List<String> lists) throws Throwable
    	{
                 ..
    	}
    The ListsSearch methods:

    Code:
    	public List<SearchDetailsPerHit> searchListsDetails(List<Hit> hitList)
    	{
                     ..
    	}
    	
    	public List<Hit> searchListsPerson(String name, List<String> lists)
    	{
                    ..
    	}
    This setup works fine when I run my unit tests, but when I build and deploy on axis2 I get the following exception:
    Code:
    jvm 1    | Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.aop.aspectj.AspectJPointcutAdvisor#0': Instantiation of bean failed; n
    ested 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: warning no match for this type name: ListsSearch [Xlint:invalidAbsoluteTypeName]
    jvm 1    |      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:239)
    jvm 1    |      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:855)
    jvm 1    |      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:765)
    jvm 1    |      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:412)
    jvm 1    |      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:383)
    jvm 1    |      at java.security.AccessController.doPrivileged(Native Method)
    jvm 1    |      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:353)
    jvm 1    |      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
    jvm 1    |      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
    jvm 1    |      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
    jvm 1    |      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
    jvm 1    |      at org.springframework.aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:87)
    jvm 1    |      at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:98)
    jvm 1    |      at org.springframework.aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:105)
    jvm 1    |      at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:244)
    jvm 1    |      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:724)
    jvm 1    |      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:695)
    jvm 1    |      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:373)
    jvm 1    |      ... 53 more
    jvm 1    | Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdvisor]: Constructor threw exception; nest
    ed exception is java.lang.IllegalArgumentException: warning no match for this type name: ListsSearch [Xlint:invalidAbsoluteTypeName]
    jvm 1    |      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:98)
    jvm 1    |      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
    jvm 1    |      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:233)
    jvm 1    |      ... 70 more
    jvm 1    | Caused by: java.lang.IllegalArgumentException: warning no match for this type name: ListsSearch [Xlint:invalidAbsoluteTypeName]
    jvm 1    |      at org.aspectj.weaver.tools.PointcutParser.parsePointcutExpression(PointcutParser.java:302)
    jvm 1    |      at org.springframework.aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:197)
    jvm 1    |      at org.springframework.aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:184)
    jvm 1    |      at org.springframework.aop.aspectj.AspectJExpressionPointcut.getMethodMatcher(AspectJExpressionPointcut.java:170)
    jvm 1    |      at org.springframework.aop.aspectj.AbstractAspectJAdvice.buildSafePointcut(AbstractAspectJAdvice.java:189)
    jvm 1    |      at org.springframework.aop.aspectj.AspectJPointcutAdvisor.<init>(AspectJPointcutAdvisor.java:51)
    jvm 1    |      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    jvm 1    |      at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    jvm 1    |      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    jvm 1    |      at java.lang.reflect.Constructor.newInstance(Unknown Source)
    jvm 1    |      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:83)
    jvm 1    |      ... 72 more
    jvm 1    | Starting SpringInitialization
    Any obvious reason why I get this exception? If I remove the aop-config, no exceptions occur on deploy.

  • #2
    do you have ListsSearch class? is it in a package? you are referencing this class in the pointcut as if it does not belong to any package...?

    Comment


    • #3
      No, it's in the default package, and the unit tests run without problems.

      Comment


      • #4
        I think I've found the problem. It has to do with the argument names. Thanks to bdangubic.

        From Spring Reference:

        2. Using the 'argNames' attribute is a little clumsy, so if the 'argNames' attribute has not been specified, then
        Spring AOP will look at the debug information for the class and try to determine the parameter names from
        the local variable table. This information will be present as long as the classes have been compiled with
        debug information ('-g:vars' at a minimum). The consequences of compiling with this flag on are: (1)
        your code will be slightly easier to understand (reverse engineer), (2) the class file sizes will be very slightly
        bigger (typically inconsequential), (3) the optimization to remove unused local variables will not be applied
        by your compiler. In other words, you should encounter no difficulties building with this flag on.
        If an @AspectJ aspect has been compiled by the AspectJ compiler (ajc) even without the debug information
        then there is no need to add the argNames attribute as the compiler will retain the needed information.
        3. If the code has been compiled without the necessary debug information, then Spring AOP will attempt to
        deduce the pairing of binding variables to parameters (for example, if only one variable is bound in the
        pointcut expression, and the advice method only takes one parameter, the pairing is obvious!). If the binding
        of variables

        Comment

        Working...
        X