Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-3150

Create CGLIB proxy instances honoring <constructor-arg> tags

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.3
    • Fix Version/s: 4.0 RC1
    • Component/s: Core:AOP
    • Labels:
      None
    • Last commented by a User:
      false

      Description

      This problem was encountered with Snapshot build 98 of version 2.0.3.

      The following bean definition of a custom-scoped bean (the class is a backport of JDK 1.5's java.util.concurrent.ArrayBlockingQueue to work on JDK 1.4):

      <bean class="edu.emory.mathcs.backport.java.util.concurrent.ArrayBlockingQueue" scope="report">
          <constructor-arg value="3" />
          <aop:scoped-proxy />
      </bean>
      

      Failed with the error below. The class in question has no empty constructor, it needs an integer value, which is specified by <constructor-arg>.

      Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'edu.emory.mathcs.backport.java.util.concurrent.ArrayBlockingQueue#55a338': Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigException: Couldn't generate CGLIB subclass of class [class edu.emory.mathcs.backport.java.util.concurrent.ArrayBlockingQueue]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
      Caused by: org.springframework.aop.framework.AopConfigException: Couldn't generate CGLIB subclass of class [class edu.emory.mathcs.backport.java.util.concurrent.ArrayBlockingQueue]: Common causes of this problem include using a final class or a non-visible class; nested exception is java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
      Caused by: java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
      	at net.sf.cglib.proxy.Enhancer.emitConstructors(Enhancer.java:718)
      	at net.sf.cglib.proxy.Enhancer.generateClass(Enhancer.java:499)
      	at net.sf.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33)
      	at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25)
      	at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
      	at net.sf.cglib.proxy.Enhancer.createHelper(Enhancer.java:377)
      	at net.sf.cglib.proxy.Enhancer.create(Enhancer.java:285)
      	at org.springframework.aop.framework.Cglib2AopProxy.getProxy(Cglib2AopProxy.java:193)
      	at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:107)
      	at org.springframework.aop.scope.ScopedProxyFactoryBean.setBeanFactory(ScopedProxyFactoryBean.java:109)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1074)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:430)
      	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBeanDefinition(BeanDefinitionValueResolver.java:197)
      	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1017)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:810)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:426)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:252)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:249)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:358)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:869)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:782)
      	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:426)
      	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:252)
      	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:144)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:249)
      	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:163)
      	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:280)
      	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:357)
      

      I am using CGLib 2.1.3 (the one that ships with Hibernate 3.2.1)

      This problem does not occur in version 2.0.0

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                juergen.hoeller Juergen Hoeller
                Reporter:
                mycroft Bruno Navert
                Last updater:
                Juergen Hoeller
              • Votes:
                15 Vote for this issue
                Watchers:
                19 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  4 years, 28 weeks, 1 day ago