3 Replies Latest reply on Aug 6, 2012 4:56 PM by ikysil

    CGLIB errors

    michel.strogoff

      Hi,

       

      I am trying to deploy a subset of a Spring 2.5.6 application on JBoss AS 7.1.1 (this application is currently running on JBoss 5.1.0 GA).

       

      I have installed Snowdrop on JBoss as explained in the manual.

       

      The application is an EAR having the following structure :

       

      app-root
           /lib
                ...
                cglib-2.1_3.jar
                ...
           /META-INF
                application.xml
                jboss-deployment-structure.xml
           
           module1.jar
      

       

      The module1.jar contains the Spring application context definition files which are loaded by org.jboss.spring.vfs.context.VFSClassPathXmlApplicationContext.

       

      After startup, Spring complains about a missing cglib library and raises an AopConfigException :

       

      Caused by: 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) [spring-aop.jar:2.5.6.SEC02]
                at org.springframework.aop.framework.ProxyCreatorSupport.createAopProxy(ProxyCreatorSupport.java:106) [spring-aop.jar:2.5.6.SEC02]
                at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:110) [spring-aop.jar:2.5.6.SEC02]
                at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:490) [spring-aop.jar:2.5.6.SEC02]
                at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:365) [spring-aop.jar:2.5.6.SEC02]
                at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:325) [spring-aop.jar:2.5.6.SEC02]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:361) [spring-beans.jar:2.5.6.SEC02]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1344) [spring-beans.jar:2.5.6.SEC02]
                at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473) [spring-beans.jar:2.5.6.SEC02]
      

       

      If I add the cglib library as a dependency of the org.springframework.spring:snowdrop module, then I get an IllegalArgumentException :

       

      java.lang.IllegalArgumentException: class com.itesoft.share.persistence.iod.multitenant.TenantInterceptor$$EnhancerByCGLIB$$398b4762_3 is not an enhanced class
                at net.sf.cglib.proxy.Enhancer.setCallbacksHelper(Enhancer.java:618) [cglib-2.1_3.jar:]
                at net.sf.cglib.proxy.Enhancer.setThreadCallbacks(Enhancer.java:609) [cglib-2.1_3.jar:]
                at net.sf.cglib.proxy.Enhancer.createUsingReflection(Enhancer.java:631) [cglib-2.1_3.jar:]
                at net.sf.cglib.proxy.Enhancer.firstInstance(Enhancer.java:538) [cglib-2.1_3.jar:]
                at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:225) [cglib-2.1_3.jar:]
                at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377) [cglib-2.1_3.jar:]
                at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285) [cglib-2.1_3.jar:]
                at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:201) [spring-aop.jar:2.5.6.SEC02]
                ... 189 more
      

       

      I don't understand why this is happening and I can't find much information about tyhe "not an enhanced class" exception.

       

      I don't encounter these errors on JBoss 5.1.0 with the same Spring and CGLIB versions.

       

      Any help would be much appreciated.

       

      Best regards,

      Eric

        • 1. Re: CGLIB errors
          ikysil

          Hi Eric,

           

          Did you solved the issue?

           

          I'm observing the same behavior with Spring 3.1. One of the Spring MVC controllers I have is configured with @Value annotation which leads (apparently) to the sub-class based proxying.

           

          PS: The interesting thing is that I'm migrating the application from Eclipse Virgo - the application works there with CGLIB deployed as an external dependency.

          • 2. Re: CGLIB errors
            michel.strogoff

            Hi Illya,

             

            I have upgraded the application to Spring 3 (which is running on JBoss 7 without the need to specify the Spring context loader explicitely) and I have embedded Spring libraries in the lib/ folder of the application.

             

            My solution is therefore not using Snowdrop.

             

            Best regards,

            Eric

            • 3. Re: CGLIB errors
              ikysil

              Thank you.

               

              It looks like the way I'm going to take as well.