Announcement Announcement Module
Collapse
No announcement yet.
HotSwappableTargetSource problem with Spring >= 1.1.2 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • HotSwappableTargetSource problem with Spring >= 1.1.2

    I've used a HotSwappableTargetSource successfully since before 1.1.1, but encounter a problem upon upgrading to Spring 1.1.2 in order to fix another issue.

    My application context for the relevant beans is as follows:

    Code:
    <bean id="swapper" class="org.springframework.aop.target.HotSwappableTargetSource">
        <constructor-arg><ref local="appXaDataSource"/></constructor-arg>
    </bean>
    <bean id="swappable" class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="targetSource">
            <ref local="swapper"/>
        </property>
    </bean>
    <bean id="appXaDataSource"
        class="org.enhydra.jdbc.standard.StandardXADataSource" singleton="false" destroy-method="shutdown"/>
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate.LocalSessionFactoryBean" lazy-init="true">
        <description>Lazy-loading session factory.</description>
        <property name="dataSource">
            <ref local="swappable"/>
        </property>
        <property name="mappingResources">
            <list>
                <value>hbm/ApplicationModel.hbm.xml</value>
                <!-- ... --> 
            </list>
        </property>
        <property name="hibernateProperties">
            <ref local="hibernateProperties"/>
        </property>
        <property name="entityInterceptor">
            <ref local="dependencyInjectionInterceptor"/>
        </property>
        <property name="jtaTransactionManager">
            <ref local="jotm"/>
        </property>
    </bean>
    In Spring 1.1.1, this works fine and reliably, but in Spring 1.1.2 (and I verified that the problem remains with today's CVS build), I get the following error:

    Code:
    org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'com.thatone.archie.persistence.ArchieHibernateDao' defined in file &#91;/home/calvins/Desktop/workspace/fud/build/archie/WEB-INF/applicationContext.xml&#93;&#58; Can't resolve reference to bean 'sessionFactory' while setting property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'sessionFactory' defined in file &#91;/home/calvins/Desktop/workspace/fud/build/archie/WEB-INF/applicationContext.xml&#93;&#58; Can't resolve reference to bean 'swappable' while setting property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'swappable' defined in file &#91;/home/calvins/Desktop/workspace/fud/build/archie/WEB-INF/applicationContext.xml&#93;&#58; Initialization of bean failed; nested exception is org.aopalliance.aop.AspectException&#58; null
    org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'sessionFactory' defined in file &#91;/home/calvins/Desktop/workspace/fud/build/archie/WEB-INF/applicationContext.xml&#93;&#58; Can't resolve reference to bean 'swappable' while setting property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'swappable' defined in file &#91;/home/calvins/Desktop/workspace/fud/build/archie/WEB-INF/applicationContext.xml&#93;&#58; Initialization of bean failed; nested exception is org.aopalliance.aop.AspectException&#58; null
    org.springframework.beans.factory.BeanCreationException&#58; Error creating bean with name 'swappable' defined in file &#91;/home/calvins/Desktop/workspace/fud/build/archie/WEB-INF/applicationContext.xml&#93;&#58; Initialization of bean failed; nested exception is org.aopalliance.aop.AspectException&#58; null
    net.sf.cglib.core.CodeGenerationException&#58; java.lang.ClassCastException-->null
    	at net.sf.cglib.core.ReflectUtils.newInstance&#40;ReflectUtils.java&#58;235&#41;
    	at net.sf.cglib.core.ReflectUtils.newInstance&#40;ReflectUtils.java&#58;220&#41;
    	at net.sf.cglib.core.ReflectUtils.newInstance&#40;ReflectUtils.java&#58;216&#41;
    	at net.sf.cglib.proxy.Enhancer.createUsingReflection&#40;Enhancer.java&#58;566&#41;
    	at net.sf.cglib.proxy.Enhancer.firstInstance&#40;Enhancer.java&#58;493&#41;
    	at net.sf.cglib.core.AbstractClassGenerator.create&#40;AbstractClassGenerator.java&#58;220&#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;233&#41;
    	at org.springframework.aop.framework.ProxyFactoryBean.setBeanFactory&#40;ProxyFactoryBean.java&#58;197&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;271&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;193&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;240&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;163&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference&#40;AbstractAutowireCapableBeanFactory.java&#58;898&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary&#40;AbstractAutowireCapableBeanFactory.java&#58;832&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues&#40;AbstractAutowireCapableBeanFactory.java&#58;773&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean&#40;AbstractAutowireCapableBeanFactory.java&#58;601&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;258&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;193&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;240&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;163&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveReference&#40;AbstractAutowireCapableBeanFactory.java&#58;898&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary&#40;AbstractAutowireCapableBeanFactory.java&#58;832&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues&#40;AbstractAutowireCapableBeanFactory.java&#58;773&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean&#40;AbstractAutowireCapableBeanFactory.java&#58;601&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;258&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveInnerBeanDefinition&#40;AbstractAutowireCapableBeanFactory.java&#58;858&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.resolveValueIfNecessary&#40;AbstractAutowireCapableBeanFactory.java&#58;823&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues&#40;AbstractAutowireCapableBeanFactory.java&#58;773&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean&#40;AbstractAutowireCapableBeanFactory.java&#58;601&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;258&#41;
    	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean&#40;AbstractAutowireCapableBeanFactory.java&#58;193&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;240&#41;
    	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean&#40;AbstractBeanFactory.java&#58;163&#41;
    	at org.springframework.context.support.AbstractApplicationContext.getBean&#40;AbstractApplicationContext.java&#58;476&#41;
    	at com.thatone.archie.config.ApplicationConfiguration.getDao&#40;ApplicationConfiguration.java&#58;140&#41;
    	at com.thatone.archie.config.ApplicationConfiguration.getDataSourceById&#40;ApplicationConfiguration.java&#58;454&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke0&#40;Native Method&#41;
    	at sun.reflect.NativeMethodAccessorImpl.invoke&#40;NativeMethodAccessorImpl.java&#58;39&#41;
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke&#40;DelegatingMethodAccessorImpl.java&#58;25&#41;
    	at java.lang.reflect.Method.invoke&#40;Method.java&#58;324&#41;
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection&#40;AopUtils.java&#58;295&#41;
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint&#40;ReflectiveMethodInvocation.java&#58;154&#41;
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed&#40;ReflectiveMethodInvocation.java&#58;121&#41;
    	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke&#40;TransactionInterceptor.java&#58;56&#41;
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed&#40;ReflectiveMethodInvocation.java&#58;143&#41;
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke&#40;JdkDynamicAopProxy.java&#58;174&#41;
    	at $Proxy0.getDataSourceById&#40;Unknown Source&#41;
    	at com.thatone.archie.engine.task.SimpleTaskHelperImplTest.setUp&#40;SimpleTaskHelperImplTest.java&#58;46&#41;
    	at junit.framework.TestCase.runBare&#40;TestCase.java&#58;125&#41;
    	at junit.framework.TestResult$1.protect&#40;TestResult.java&#58;106&#41;
    	at junit.framework.TestResult.runProtected&#40;TestResult.java&#58;124&#41;
    	at junit.framework.TestResult.run&#40;TestResult.java&#58;109&#41;
    	at junit.framework.TestCase.run&#40;TestCase.java&#58;118&#41;
    	at junit.framework.TestSuite.runTest&#40;TestSuite.java&#58;208&#41;
    	at junit.framework.TestSuite.run&#40;TestSuite.java&#58;203&#41;
    	at junit.framework.TestSuite.runTest&#40;TestSuite.java&#58;208&#41;
    	at junit.framework.TestSuite.run&#40;TestSuite.java&#58;203&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests&#40;RemoteTestRunner.java&#58;421&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run&#40;RemoteTestRunner.java&#58;305&#41;
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main&#40;RemoteTestRunner.java&#58;186&#41;
    Caused by&#58; java.lang.ClassCastException
    	at org.enhydra.jdbc.standard.StandardXADataSource$$EnhancerByCGLIB$$2b71cd79_2$$FastClassByCGLIB$$68f36b1e.invoke&#40;<generated>&#41;
    	at net.sf.cglib.proxy.MethodProxy.invokeSuper&#40;MethodProxy.java&#58;167&#41;
    	at org.springframework.aop.framework.Cglib2AopProxy$AbstractInterceptor.doInvoke&#40;Cglib2AopProxy.java&#58;342&#41;
    	at org.springframework.aop.framework.Cglib2AopProxy$DynamicUnadvisedInterceptor.intercept&#40;Cglib2AopProxy.java&#58;414&#41;
    	at org.enhydra.jdbc.standard.StandardXADataSource$$EnhancerByCGLIB$$2b71cd79_2.setLogger&#40;<generated>&#41;
    	at org.enhydra.jdbc.standard.StandardDataSource.<init>&#40;StandardDataSource.java&#58;68&#41;
    	at org.enhydra.jdbc.standard.StandardConnectionPoolDataSource.<init>&#40;StandardConnectionPoolDataSource.java&#58;46&#41;
    	at org.enhydra.jdbc.standard.StandardXADataSource.<init>&#40;StandardXADataSource.java&#58;70&#41;
    	at org.enhydra.jdbc.standard.StandardXADataSource$$EnhancerByCGLIB$$2b71cd79_2.<init>&#40;<generated>&#41;
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance0&#40;Native Method&#41;
    	at sun.reflect.NativeConstructorAccessorImpl.newInstance&#40;NativeConstructorAccessorImpl.java&#58;39&#41;
    	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance&#40;DelegatingConstructorAccessorImpl.java&#58;27&#41;
    	at java.lang.reflect.Constructor.newInstance&#40;Constructor.java&#58;274&#41;
    	at net.sf.cglib.core.ReflectUtils.newInstance&#40;ReflectUtils.java&#58;228&#41;
    	... 63 more
    I've checked the release notes for 1.1.2, and have searched the forums and jira, but did not find anything helpful.

    Does anybody know what might have changed between 1.1.1 and 1.1.2 that could cause this behavior?

    Thanks for any information....

    -calvin

  • #2
    Calvin,

    I'm going to look into this a bit more. The only thing that changed between 1.1.1 and 1.1.2 in this class was that we added a partial workaround to a problem in CGLIB that causes bean state to be reset to any default values set by the constructor. As it turns out we can't completely fix this problem in Spring and we are awaiting a fix in CGLIB.

    You problem seems to lie somewhere near the modified code. I will update this topic when I know more.

    Rob

    Comment


    • #3
      Calvin,

      I have found the problem you are experiencing and I have raised an issue in JIRA (SPR-529). I will be committing a fix to CVS today which should make it into the 1.1.3 release in the next few days.

      I apologize for any problems you have encoutered related to this issue.

      Rob

      Comment


      • #4
        Thanks, Rob. That's great news. I'll be watching for the commit in CVS. If you are able to update this thread when you commit, that would be wonderful, as I'll get an email notification and can build from CVS immediately.

        Thanks again...

        -calvin

        Comment


        • #5
          Got the update from CVS and verified that I'm back in Spring nirvana again.

          Thanks very much for taking care of this so quickly.

          Comment

          Working...
          X