Announcement Announcement Module
No announcement yet.
aop:after-returning causes NullPointerException when deployed Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • aop:after-returning causes NullPointerException when deployed

    Hi All,

    I have created my first Spring AOP aspect to test out a very simple logging feature.
    The code works as expected but only in my local IDE. When deployed to a production
    environment then a NullPointerException is thrown as the web application is started.

    The problem has something to do with the aop:after-returning setting. If I comment it
    out from the configuration then no exception is thrown in production. Does anybody
    know why there would be a difference between my IDE and deployed environments?


    Here is the Spring configuration:
    <bean id="methodLogger" class="com.eob.util.aop.MethodLogger"/>
    <aop:aspect id="loggingAspect" ref="methodLogger">
    <aop: pointcut id="servicePointcut" expression="execution(* com.eob..*Service+.*(..))"/>
    <aop:before method="logMethodEntry" pointcut-ref="servicePointcut"/>
    <aop:after-returning method="logMethodExit" returning="result" pointcut-ref="servicePointcut"/>

    Here are the environments:
    IDE: IBM RAD 7 with a local single WAS 6.1 application server node, running under WinXP
    Deployed: A single WAS 6.1 application server node, running under Redhat Linux 4
    Java 5.0
    Spring 2.5.5

    Here is part of the stack trace:
    Caused by: org.springframework.beans.BeanInstantiationExcepti on: Could not instantiate bean class [org.springframework.aop.aspectj.AspectJPointcutAdv isor]: Constructor threw exception; nested exception is java.lang.NullPointerException
    at org.springframework.beans.BeanUtils.instantiateCla ss(
    at stantiationStrategy.instantiate(SimpleInstantiatio
    at torResolver.autowireConstructor(ConstructorResolve
    ... 52 more

    Caused by: java.lang.NullPointerException
    at java.util.concurrent.ConcurrentHashMap.put(Concurr
    at org.springframework.core.LocalVariableTableParamet erNameDiscoverer.getParameterNames(LocalVariableTa
    at org.springframework.core.PrioritizedParameterNameD iscoverer.getParameterNames(PrioritizedParameterNa
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.bindArgumentsByName( :422)
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.calculateArgumentBindings(AbstractAspectJAdvic
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.getPointcut(
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.buildSafePointcut( 88)
    at org.springframework.aop.aspectj.AspectJPointcutAdv isor.<init>(
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(
    at java.lang.reflect.Constructor.newInstance(Construc
    at org.springframework.beans.BeanUtils.instantiateCla ss(
    ... 54 more

  • #2
    What is the signature of the MethodLogger.logMethodExit() method?

    Post complete standalone test-case here to get real help.


    • #3
      Здравствуйте Denis!

      Here is the signature of the MethodLogger.logMethodExit() method:

      public void logMethodExit(StaticPart staticPart, Object result);

      If this is still not enough information then I'll create a standalone test-case.