Announcement Announcement Module
Collapse
No announcement yet.
AOP Issues with non-Spring instantiated Groovy script bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP Issues with non-Spring instantiated Groovy script bean

    This seems to be somewhat related to http://opensource.atlassian.com/proj...rowse/SPR-3223

    I am instantiating a Groovy bean using a GroovyClassLoader, and then handing it to a Spring context to be wired.

    I'm getting the following exception:

    org.aspectj.weaver.reflect.ReflectionWorld$Reflect ionWorldException: warning can't determine implemented interfaces of missing type net.vitarara.quadran.core.web.shipping.ListShipmen tsAction [Xlint:cantFindType]

    org.aspectj.weaver.reflect.ReflectionWorld$Excepti onBasedMessageHandler.handleMessage(ReflectionWorl d.java:163)
    org.aspectj.weaver.Lint$Kind.signal(Lint.java:287)
    org.aspectj.weaver.MissingResolvedTypeWithKnownSig nature.raiseCantFindType(MissingResolvedTypeWithKn ownSignature.java:198)
    org.aspectj.weaver.MissingResolvedTypeWithKnownSig nature.getDeclaredInterfaces(MissingResolvedTypeWi thKnownSignature.java:76)
    org.aspectj.weaver.ResolvedType.getDirectSupertype s(ResolvedType.java:65)
    org.aspectj.weaver.JoinPointSignatureIterator.find SignaturesFromSupertypes(JoinPointSignatureIterato r.java:164)
    org.aspectj.weaver.JoinPointSignatureIterator.hasN ext(JoinPointSignatureIterator.java:69)
    org.aspectj.weaver.patterns.SignaturePattern.match es(SignaturePattern.java:287)
    org.aspectj.weaver.patterns.KindedPointcut.matchIn ternal(KindedPointcut.java:106)
    org.aspectj.weaver.patterns.Pointcut.match(Pointcu t.java:146)
    org.aspectj.weaver.internal.tools.PointcutExpressi onImpl.getShadowMatch(PointcutExpressionImpl.java: 235)
    org.aspectj.weaver.internal.tools.PointcutExpressi onImpl.matchesExecution(PointcutExpressionImpl.jav a:101)
    org.aspectj.weaver.internal.tools.PointcutExpressi onImpl.matchesMethodExecution(PointcutExpressionIm pl.java:92)
    org.springframework.aop.aspectj.AspectJExpressionP ointcut.getShadowMatch(AspectJExpressionPointcut.j ava:305)
    org.springframework.aop.aspectj.AspectJExpressionP ointcut.matches(AspectJExpressionPointcut.java:200 )
    org.springframework.aop.support.AopUtils.canApply( AopUtils.java:183)
    org.springframework.aop.support.AopUtils.canApply( AopUtils.java:226)
    org.springframework.aop.support.AopUtils.findAdvis orsThatCanApply(AopUtils.java:256)
    org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.findEligibleAdvisors(Abs tractAdvisorAutoProxyCreator.java:85)
    org.springframework.aop.framework.autoproxy.Abstra ctAdvisorAutoProxyCreator.getAdvicesAndAdvisorsFor Bean(AbstractAdvisorAutoProxyCreator.java:69)
    org.springframework.aop.framework.autoproxy.Abstra ctAutoProxyCreator.postProcessAfterInitialization( AbstractAutoProxyCreator.java:265)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyBeanPostProcessors AfterInitialization(AbstractAutowireCapableBeanFac tory.java:316)


    I've gone down this road of instantiating my own Groovy beans because the scripting support in Spring seems to wrap scripted beans in a proxy, requiring that they implement an interface for all methods one would want to publicly expose. That just too much work. (http://forum.springframework.org/showthread.php?t=35958)

    I would dig into this, but I will readily admit that I am completely out of my depth here. I barely understand what a pointcut is.

    What seems very strange to me is that the GroovyClassLoader that created the bean is the classloader that my Spring context should be using.

    Code:
        public void setServletContext(ServletContext servletContext) {
            log.info ("Groovy Spring Plugin: Initializing");
    
            // Create the Groovy classloader and make it a child of the current thread's class loader.
            CompilerConfiguration cc = new CompilerConfiguration ();
            cc.setRecompileGroovySource (true);
            gcl = new GroovyClassLoader (Thread.currentThread().getContextClassLoader (), cc);
            
            ...
    
            ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
    
            ...
    
            // Set the appContext's class loader to the GroovyClassLoader. The refresh the context.
            ((org.springframework.core.io.DefaultResourceLoader) appContext).setClassLoader (gcl);
            ((ConfigurableWebApplicationContext) appContext).refresh ();
    
        }
    I would think that having made the classloader of the context the GroovyClassLoader it ought to be able to figure out what interfaces my groovy bean implements.

    Mark

  • #2
    Ugh... I had the wrong Spring dependency in my pom.xml file. Changed it to 2.0.3 and the issue is gone.

    Too many pom files and example apps floating around for me.

    Mark

    Comment

    Working...
    X