Announcement Announcement Module
Collapse
No announcement yet.
CommonsPoolTargetSource and Constructor Injection Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • CommonsPoolTargetSource and Constructor Injection

    I am attempting to use CommonsPoolTargetSource to manage instances of an object that expects a Properties object passed to the constructor, then apply ProxyFactoryBean to enable pooling within my application. I am working with Spring Framework 1.1.3.

    Here is the definition of the target:
    Code:
        <bean id="delegateTarget" class="wrk.DirectoryInquiryDelegate" singleton="false">
            <constructor-arg>
                <props>
                    <prop key="java.naming.provider.url">$&#123;java.naming.provider.url&#125;</prop>
                    <prop key="java.naming.security.principal">$&#123;java.naming.security.principal&#125;</prop>
                    <prop key="java.naming.security.credentials">$&#123;java.naming.security.credentials&#125;</prop>
                </props>
            </constructor-arg>
        </bean>
    Here is the declaration for the target source:
    Code:
        <bean  id="poolTargetSource" class="org.springframework.aop.target.CommonsPoolTargetSource">
          <property name="targetBeanName"><value>delegateTarget</value></property>
          <property name="maxSize"><value>5</value></property>
        </bean>
    And finally, here is the proxy factory:
    Code:
        <bean  id="delegate" class="org.springframework.aop.framework.ProxyFactoryBean">
          <property name="targetSource"><ref local="poolTargetSource"/></property>
        </bean>
    Everything seems to be ok right up to the point of initializing the proxy, at which point the following exception is thrown:
    Code:
    org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'delegate' defined in class path resource &#91;csilContext.xml&#93;&#58; Initialization of bean failed; nested exception is org.aopalliance.aop.AspectException&#58; null
    java.lang.IllegalArgumentException&#58; Superclass has no null constructors but no arguments were given
    	at net.sf.cglib.proxy.Enhancer.emitConstructors&#40;Enhancer.java&#58;783&#41;
    	at net.sf.cglib.proxy.Enhancer.emit&#40;Enhancer.java&#58;749&#41;
    	at net.sf.cglib.proxy.Enhancer.generateClass&#40;Enhancer.java&#58;481&#41;
    	at net.sf.cglib.transform.TransformingClassGenerator.generateClass&#40;TransformingClassGenerator.java&#58;33&#41;
    	at net.sf.cglib.core.DefaultGeneratorStrategy.generate&#40;DefaultGeneratorStrategy.java&#58;25&#41;
    	at net.sf.cglib.core.AbstractClassGenerator.create&#40;AbstractClassGenerator.java&#58;215&#41;
    	at net.sf.cglib.proxy.Enhancer.createHelper&#40;Enhancer.java&#58;368&#41;
    	at net.sf.cglib.proxy.Enhancer.create&#40;Enhancer.java&#58;280&#41;
    	at org.springframework.aop.framework.Cglib2AopProxy.getProxy&#40;Cglib2AopProxy.java&#58;163&#41;
    	at org.springframework.aop.framework.Cglib2AopProxy.getProxy&#40;Cglib2AopProxy.java&#58;124&#41;
    	at org.springframework.aop.framework.ProxyFactoryBean.getSingletonInstance&#40;ProxyFactoryBean.java&#58;241&#41;
    	at org.springframework.aop.framework.ProxyFactoryBean.setBeanFactory&#40;ProxyFactoryBean.java&#58;201&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;301&#41;
    It is distinctly possible that I have misunderstood the configuration requirements for the use of the Commons Pool Target Source but I can't seem to figure out what I am doing wrong.

    Any advice would be greatly appreciated!

  • #2
    Is this related to Cannot proxy classes lacking no-arg constructor using CGLIB?

    Comment

    Working...
    X