Announcement Announcement Module
Collapse
No announcement yet.
ServiceLoaderFactoryBean.beanClassLoader being incorrectly overwritten Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ServiceLoaderFactoryBean.beanClassLoader being incorrectly overwritten

    I am using the ServiceLoaderFactoryBean class in spring-bean 3.0.5.RELEASE with a MyCustomClassLoader as value of ServiceLoaderFactoryBean.beanClassLoader.

    I am finding that the org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory is behaving unexpectedly and initially setting the property to MyCustomClassLoader as expected but then changing it to the default ClassLoader Launcher$AppClassLoader.

    Am I doing something wrong or is there a bug at play.

    Here is my spring configuration:

    Code:
        <bean id="MyCustomClassLoader" class="my.package.MyCustomClassLoader" scope="singleton" lazy-init="true" />
            
        <bean id="MyServiceLoaderFactoryBean" class="org.springframework.beans.factory.serviceloader.ServiceLoaderFactoryBean" scope="singleton" lazy-init="false">
            <property name="serviceType" value="my.package.MyServiceClass"/>
            <property name="beanClassLoader" ref="MyCustomClassLoader"/>
        </bean>
    I notice in the debugger that there a ServiceLoaderFactoryBean inheritance hierarchy where the beanClassLoader property is defined private first in AbstractFactoryBean and then again in AbstractServiceLoaderBasedFactoryBean.

    I notice in debugger that:
    • AbstractAutowireCapableBeanFactory.doCreateBean initially sets both beanClassLoader properties to the default ClassLoader Launcher$AppClassLoader
    • It then sets the second beanClassLoader property to MyCustomClassLoader after calling populateBean (good)
    • It then calls initializeBean where the second beanClassLoader property gets reset back to the default ClassLoader Launcher$AppClassLoader (bad)

    I tried modifying the code so there is only one protected beanClassLoader property in AbstractFactoryBean and no overriding second property of same name in AbstractServiceLoaderBasedFactoryBean. The result is the same - the now single beanClassLoader property in AbstractFactoryBean is unexpectedly reset to the default ClassLoader Launcher$AppClassLoader.

    Is this a known issue? ShalI I file an issue? Is there a workaround? Thanks for your help.
    Last edited by farrukh_najmi; Aug 28th, 2012, 11:00 AM.

  • #2
    I have created https://jira.springsource.org/browse/SPR-9787 on this and would be grateful for any help on workarounds.

    Comment

    Working...
    X