Announcement Announcement Module
Collapse
No announcement yet.
Working bean gives error with <aop:scoped-proxy/> Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Working bean gives error with <aop:scoped-proxy/>

    Hi,

    <bean id="xxx" class="org.springframework.validation.BeanProperty BindingResult" scope="request">
    <constructor-arg ref="sel"/>
    <constructor-arg value="sel"/>
    <aop:scoped-proxy/>
    </bean>

    Gives following error:

    Error creating bean with name 'xxx': Initialization of bean failed; nested exception is org.springframework.aop.framework.AopConfigExcepti on: Couldn't generate CGLIB subclass of class [class org.springframework.validation.BeanPropertyBinding Result]: 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

    The bean functionally works if "<aop" tag is removed.

    Please help. Thanks in advance.
    Environment: Spring 2.0, Tomcat 5.0, J2SE 5

  • #2
    I could find cause of the problem. But do not know the fix yet..
    Cause: The problem appears when bean has constructor arguments.

    Following simple bean works fine in request scope if "ctr" is set as property. But it throws the exact same error if iconstructor argument is used as an initializer

    <bean id="abc" class="spa.bus.Time" scope="request">
    <constructor-arg value="100"/>
    <!--property name="ctr" value="0"></property-->
    <aop:scoped-proxy/>
    </bean>

    Error:
    java.lang.IllegalArgumentException: Superclass has no null constructors but no arguments were given
    net.sf.cglib.proxy.Enhancer.emitConstructors(Enhan cer.java:718)
    net.sf.cglib.proxy.Enhancer.generateClass(Enhancer .java:499)
    net.sf.cglib.transform.TransformingClassGenerator. generateClass(TransformingClassGenerator.java:33)
    net.sf.cglib.core.DefaultGeneratorStrategy.generat e(DefaultGeneratorStrategy.java:25)
    net.sf.cglib.core.AbstractClassGenerator.create(Ab stractClassGenerator.java:216)
    net.sf.cglib.proxy.Enhancer.createHelper(Enhancer. java:377)
    net.sf.cglib.proxy.Enhancer.create(Enhancer.java:2 85)
    org.springframework.aop.framework.Cglib2AopProxy.g etProxy(Cglib2AopProxy.java:202)
    org.springframework.aop.framework.Cglib2AopProxy.g etProxy(Cglib2AopProxy.java:147)
    org.springframework.aop.framework.ProxyFactory.get Proxy(ProxyFactory.java:72)
    org.springframework.aop.scope.ScopedProxyFactoryBe an.setBeanFactory(ScopedProxyFactoryBean.java:100)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.initializeBean(Abstract AutowireCapableBeanFactory.java:1020)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:420)
    org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 45)
    org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:141)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:242)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:156)
    org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:246)
    org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:128)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:955)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:729)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:416)
    org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 45)
    org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:141)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:242)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:156)
    org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveReference(BeanDefinitio nValueResolver.java:246)
    org.springframework.beans.factory.support.BeanDefi nitionValueResolver.resolveValueIfNecessary(BeanDe finitionValueResolver.java:128)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.applyPropertyValues(Abs tractAutowireCapableBeanFactory.java:955)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:729)
    org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:416)
    org.springframework.beans.factory.support.Abstract BeanFactory$1.getObject(AbstractBeanFactory.java:2 45)
    org.springframework.beans.factory.support.DefaultS ingletonBeanRegistry.getSingleton(DefaultSingleton BeanRegistry.java:141)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:242)
    org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:156)
    org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:290)
    org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:348)
    org.springframework.web.context.support.AbstractRe freshableWebApplicationContext.refresh(AbstractRef reshableWebApplicationContext.java:156)
    org.springframework.web.servlet.FrameworkServlet.c reateWebApplicationContext(FrameworkServlet.java:3 08)
    org.springframework.web.servlet.FrameworkServlet.i nitWebApplicationContext(FrameworkServlet.java:252 )
    org.springframework.web.servlet.FrameworkServlet.i nitServletBean(FrameworkServlet.java:221)
    org.springframework.web.servlet.HttpServletBean.in it(HttpServletBean.java:115)
    javax.servlet.GenericServlet.init(GenericServlet.j ava:211)
    org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:105)
    org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:148)
    org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:869)
    org.apache.coyote.http11.Http11BaseProtocol$Http11 ConnectionHandler.processConnection(Http11BaseProt ocol.java:664)
    org.apache.tomcat.util.net.PoolTcpEndpoint.process Socket(PoolTcpEndpoint.java:527)
    org.apache.tomcat.util.net.LeaderFollowerWorkerThr ead.runIt(LeaderFollowerWorkerThread.java:80)
    org.apache.tomcat.util.threads.ThreadPool$ControlR unnable.run(ThreadPool.java:684)
    java.lang.Thread.run(Thread.java:595)

    Is this a limitation of CGLIB?

    Thanks

    Comment


    • #3
      Check this out.
      http://forum.springframework.org/arc...p/t-27966.html

      If the documentation isn't clear on this though, it would be good to add a JIRA request!
      Last edited by karldmoore; Dec 5th, 2006, 06:06 AM.

      Comment


      • #4
        Thanks. Looks like this problem is reported earlier in JIRA http://opensource.atlassian.com/proj...browse/SPR-285 with status as "Resolution: Won't Fix"..

        Comment


        • #5
          One issue is that CGLib only handles no-arg constructors. It's quite obvious that this won't be fixed by Spring.

          Another issue is the limitation of <aop:scoped-proxy/> to CGLib. Here it would be nice to have an option to switch to dynamic proxies as it is possible with the provided alternative of ScopedProxyFactoryBean.

          Jörg

          Comment


          • #6
            Even if this is something that won't be fixed by Spring, there is a documentation issue here surely. Unless of course the documentation clearly spells this out. If it does, I retract my previous statement.

            Comment

            Working...
            X