Results 1 to 4 of 4

Thread: auto-proxying and CFLIB error on application initialization

  1. #1
    Join Date
    Dec 2009
    Posts
    4

    Default auto-proxying and CFLIB error on application initialization

    I am trying to setup @AspectJ autoproxying in Spring through the
    Code:
    <aop:aspectj-autoproxy/>
    tag. However, when my application is initializing, I am getting spring configuration errors when initializing my normal POJO beans:

    Code:
    Initialization of bean failed; nested exception is: org.springframework.aop.framework.AopConfigException: Cannot proxy target class because CGLIB2 is not available. Add CGLIB to the class path or specify proxy interfaces.
    	at org.springframework.aop.framework.DefaultAopProxyFactory.createAopProxy(DefaultAopProxyFactory.java:67)
    	at org.springframework.aop.framework.ProxyCreatorSupport.createAopProxy(ProxyCreatorSupport.java:104)
    	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:112)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:476)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:362)
    	at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:322)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:404)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1407)
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:512)
    	... 166 more
    If I remove
    Code:
    <aop:aspectj-autoproxy/>
    my application initializes without problems. I do not want to use CGLIB, so is there a way to avoid the CGLIB dependency? Any help would be appreciated.

    Thanks.
    Last edited by garrett0168; Dec 7th, 2009 at 02:34 PM.

  2. #2
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    As the message indicates, you don't have CGLIB jars in your classpath. Add those and the problem should go away.

    -Ramnivas
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

  3. #3
    Join Date
    Dec 2009
    Posts
    4

    Default

    Hi Ramnivas - Thanks for your reply. I know adding the jar to my classpath will fix the problem, but I don't want the dependency on CGLIB. Is there no other way to avoid using CGLIB?

  4. #4
    Join Date
    Jun 2006
    Location
    SF Bay Area, California
    Posts
    524

    Default

    You probably have a target class that doesn't implement an interface. Here Spring needs to use CGLIB to dynamically create a subclass. If you can manage to put an interface to such a class, you can avoid CGLIB dependency.

    -Ramnivas
    Ramnivas Laddad (Follow me on Twitter)
    AspectJ in Action: Enterprise AOP with Spring Applications (2nd edition). Now available!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •