Announcement Announcement Module
Collapse
No announcement yet.
aop:after-returning causes NullPointerException when deployed Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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?

    Thanks,
    Steve

    Here is the Spring configuration:
    <bean id="methodLogger" class="com.eob.util.aop.MethodLogger"/>
    <aop:config>
    <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"/>
    </aop:aspect>
    </aop:config>

    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(BeanUtils.java:98)
    at org.springframework.beans.factory.support.SimpleIn stantiationStrategy.instantiate(SimpleInstantiatio nStrategy.java:87)
    at org.springframework.beans.factory.support.Construc torResolver.autowireConstructor(ConstructorResolve r.java:233)
    ... 52 more

    Caused by: java.lang.NullPointerException
    at java.util.concurrent.ConcurrentHashMap.put(Concurr entHashMap.java:861)
    at org.springframework.core.LocalVariableTableParamet erNameDiscoverer.getParameterNames(LocalVariableTa bleParameterNameDiscoverer.java:69)
    at org.springframework.core.PrioritizedParameterNameD iscoverer.getParameterNames(PrioritizedParameterNa meDiscoverer.java:54)
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.bindArgumentsByName(AbstractAspectJAdvice.java :422)
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.calculateArgumentBindings(AbstractAspectJAdvic e.java:377)
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.getPointcut(AbstractAspectJAdvice.java:178)
    at org.springframework.aop.aspectj.AbstractAspectJAdv ice.buildSafePointcut(AbstractAspectJAdvice.java:1 88)
    at org.springframework.aop.aspectj.AspectJPointcutAdv isor.<init>(AspectJPointcutAdvisor.java:51)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:67)
    at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Construc tor.java:522)
    at org.springframework.beans.BeanUtils.instantiateCla ss(BeanUtils.java:83)
    ... 54 more

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

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

    Comment


    • #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.

      Thanks,
      Steve

      Comment

      Working...
      X