Back Forum Reply New

Spring AOP pointcut trouble with Axis2

Here is my aop:config:Code:
lt;bean id=quot;biwsLoggerquot; class=quot;log.BIWSLoggerquot;gt;
lt;constructor-arg type=quot;java.lang.Stringquot;gt;
lt;valuegt;conf/log.propertieslt;/valuegt;
lt;/constructor-arggt;
lt;/beangt;

lt;aop:configgt;
lt;aop:aspect id=quot;loggerAspectquot; ref=quot;biwsLoggerquot;gt;
lt;aop:pointcut id=quot;getListDetailsPointCutquot; expression=quot;execution(* ListsSearch.searchListsDetails(..)) and args(hitList)quot;/gt;
lt;aop:pointcut id=quot;searchListsPointCutquot; expression=quot;execution(* ListsSearch.searchListsPerson(..)) and args(name, lists)quot;/gt;
lt;aop:around pointcut-ref=quot;getListDetailsPointCutquot; method=quot;logGetListDetailsquot;/gt;
lt;aop:around pointcut-ref=quot;searchListsPointCutquot; method=quot;logSearchListsquot;/gt;
lt;/aop:aspectgt;
lt;/aop:configgt;
The biwsLogger methods:Code:
public Object logGetListDetails(ProceedingJoinPoint proceedingJoinPoint, Listlt;Hitgt; hitList) throws Throwable
{
..       }

public Object logSearchLists(ProceedingJoinPoint proceedingJoinPoint, String name, Listlt;Stringgt; lists) throws Throwable
{ ..
}
The ListsSearch methods:Code:
public Listlt;SearchDetailsPerHitgt; searchListsDetails(Listlt;Hitgt; hitList)
{     ..
}

public Listlt;Hitgt; searchListsPerson(String name, Listlt;Stringgt; 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..beans.factory.BeanCreationException: Error creating bean with name 'org..aop.aspectj.AspectJPointcutAdvisor#0': Instantiation of bean failed; n
ested exception is org..beans.BeanInstantiationException: Could not instantiate bean class [org..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..beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:239)
jvm 1    |      at org..beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:855)
jvm 1    |      at org..beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:765)
jvm 1    |      at org..beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:412)
jvm 1    |      at org..beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:383)
jvm 1    |      at java.security.AccessController.doPrivileged(Native Method)
jvm 1    |      at org..beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:353)
jvm 1    |      at org..beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:245)
jvm 1    |      at org..beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:169)
jvm 1    |      at org..beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:242)
jvm 1    |      at org..beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
jvm 1    |      at org..aop.framework.autoproxy.BeanFactoryAdvisorRetrievalHelper.findAdvisorBeans(BeanFactoryAdvisorRetrievalHelper.java:87)
jvm 1    |      at org..aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findCandidateAdvisors(AbstractAdvisorAutoProxyCreator.java:98)
jvm 1    |      at org..aop.aspectj.autoproxy.AspectJAwareAdvisorAutoProxyCreator.shouldSkip(AspectJAwareAdvisorAutoProxyCreator.java:105)
jvm 1    |      at org..aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessBeforeInstantiation(AbstractAutoProxyCreator.java:244)
jvm 1    |      at org..beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:724)
jvm 1    |      at org..beans.factory.support.AbstractAutowireCapableBeanFactory.resolveBeforeInstantiation(AbstractAutowireCapableBeanFactory.java:695)
jvm 1    |      at org..beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:373)
jvm 1    |      ... 53 more
jvm 1    | Caused by: org..beans.BeanInstantiationException: Could not instantiate bean class [org..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..beans.BeanUtils.instantiateClass(BeanUtils.java:98)
jvm 1    |      at org..beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
jvm 1    |      at org..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..aop.aspectj.AspectJExpressionPointcut.buildPointcutExpression(AspectJExpressionPointcut.java:197)
jvm 1    |      at org..aop.aspectj.AspectJExpressionPointcut.checkReadyToMatch(AspectJExpressionPointcut.java:184)
jvm 1    |      at org..aop.aspectj.AspectJExpressionPointcut.getMethodMatcher(AspectJExpressionPointcut.java:170)
jvm 1    |      at org..aop.aspectj.AbstractAspectJAdvice.buildSafePointcut(AbstractAspectJAdvice.java:189)
jvm 1    |      at org..aop.aspectj.AspectJPointcutAdvisor.lt;initgt;(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..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.

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...?

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

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
¥
Back Forum Reply New