Announcement Announcement Module
Collapse
No announcement yet.
aspectjweaver, spring npe with weblogic10 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • aspectjweaver, spring npe with weblogic10

    We've currently got acegi filtering service getter and finder methods. I'm trying to do the same thing for domain object methods. This setup works fine in unit test, but has problems when deploying under weblogic10.

    The components:
    (1) A home-grown @Aspect-annotated class - ResultsFilter. Very small - has a property for the acegi securityInterceptor, which it calls. This is the glue between the domain object getter and acegi. The single advice method in this class has @Around annotation. It calls the target method, then calls acegi to do the filtering, and finally returns the modified-by-acegi results back to the caller, so it acts just as a relay between the target class and acegi.

    (2) The aspect is defined as a spring-bean using the aop:aspectj-autoproxy tag, like so

    Code:
    <bean id="resultsFilter" class="org.company.core.aop.ResultsFilter"
            factory-method="aspectOf">
        <property name="afterInvocationManager">
            <ref bean="afterInvocationManager" />
        </property>
    </bean>
    
    <aop:aspectj-autoproxy>
        <aop:include name="resultsFilter" />
    </aop:aspectj-autoproxy>
    (3) The class is defined to aspectjweaver through META-INF/aop.xml

    Code:
     
    <aspects>
         <aspect name="org.company.core.aop.ResultsFilter"/>
     </aspects>
    Pointcuts and all are defined inside the ResultsFilter class for now. Junit has the javaagent argument set up like so

    Code:
    <junit blah blah>
      <jvmarg value="-javaagent:${lib.dir}/aspectjweaver.jar" />
      ...
    </junit>
    During testing, the ResultsFilter is correctly created, the acegi bean is injected and usable, and everything happens as expected.

    Deploying to weblogic creates the problem. I've got the -javaagent argument to weblogic set up like so

    Code:
    -javaagent:C:/java/shared_libs/aspectjweaver.jar
    And now on app startup, I see this stacktrace.

    Code:
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ResultsFilter' defined in ServletContext resource [/WEB-INF/applicationContext-acegi.xml]: Initialization of bean failed; nested exception is java.lang.NullPointerException
    Caused by:
    java.lang.NullPointerException
        at org.aspectj.weaver.reflect.Java15AnnotationFinder.getAnnotations(Java15AnnotationFinder.java:107)
        at org.aspectj.weaver.reflect.ReflectionBasedResolvedMemberImpl.unpackAnnotations(ReflectionBasedResolvedMemberImpl.java:174)
        at org.aspectj.weaver.reflect.ReflectionBasedResolvedMemberImpl.hasAnnotation(ReflectionBasedResolvedMemberImpl.java:158)
        at org.aspectj.weaver.patterns.ExactAnnotationTypePattern.matches(ExactAnnotationTypePattern.java:82)
        at org.aspectj.weaver.patterns.AnnotationPointcut.matchInternal(AnnotationPointcut.java:150)
        at org.aspectj.weaver.patterns.Pointcut.match(Pointcut.java:146)
        at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.getShadowMatch(PointcutExpressionImpl.java:235)
        at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesExecution(PointcutExpressionImpl.java:101)
        at org.aspectj.weaver.internal.tools.PointcutExpressionImpl.matchesMethodExecution(PointcutExpressionImpl.java:92)
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.getShadowMatch(AspectJExpressionPointcut.java:345)
        at org.springframework.aop.aspectj.AspectJExpressionPointcut.matches(AspectJExpressionPointcut.java:231)
        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:195)
        at org.springframework.aop.support.AopUtils.canApply(AopUtils.java:236)
        at org.springframework.aop.support.AopUtils.findAdvisorsThatCanApply(AopUtils.java:270)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.findEligibleAdvisors(AbstractAdvisorAutoProxyCreator.java:83)
        at org.springframework.aop.framework.autoproxy.AbstractAdvisorAutoProxyCreator.getAdvicesAndAdvisorsForBean(AbstractAdvisorAutoProxyCreator.java:66)
        at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:296)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:312)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1180)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:425)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:287)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
        at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:244)
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:187)
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:49)
        at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run(EventsManager.java:458)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(Unknown Source)
        at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(EventsManager.java:168)
        at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1721)
    (rest of weblogic stack pruned)

    The aspectj source is a little obtuse right where it's failing, and I'm unsure what actually is null. I fear that there are classloader issues between the weaver and the spring beans, but that may be a red herring.

    The problem seems to go away to some extent when removing the spring-bean definition bit. The Aspect properly fires around the intended domain-object method call, but since the aspect isn't managed by spring, it doesn't have the acegi filter bean injected.

    Any advice? (no pun intended)

    Thanks in advance.
    - Mark

  • #2
    I ran into this problem, and the cause turned out to be a stale jar from my application floating around. I changed the signature of a method on an interface, and the old version was hanging around in one jar, with the new version in another jar, all on my classpath. Chaos ensued.

    Perhaps this will help some intrepid googler....

    Comment

    Working...
    X