Announcement Announcement Module
No announcement yet.
Problem proxying factory-instantiated bean Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem proxying factory-instantiated bean

    I am trying to proxy a factory-instantiated dataSource bean using the <aop:scoped-proxy/> element in my bean, but I get the following error in the ScopedProxyFactoryBean when it tries to proxy the bean:

    java.lang.IllegalStateException: Cannot create scoped proxy for bean 'scopedTarget.dataSource': Target type could not be determined at the time of proxy creation.

    Doesthe scoped bean factory work with factory instantiated beans?

    My dataSource code is legacy code, so I need to use a factory to instantiate it, but the dataSource has 'session' scope so i need to proxy it in order to use it with the transaction manager.

    My data layer bean defs look like this:

    <!-- DataSource Factory Bean (instance factory) -->    
    <bean id="dataSourceFactory" class="" factory-method="instance">
    <bean id="dataSource" factory-bean="dataSourceFactory" factory-method="getDataSource" init-method="init" scope="request">
        	<constructor-arg value="/com/myorg/resource/datasource-config-application.xml"/>
    Any help would be appreciated...

    ~ strykker

  • #2
    It says it can not determine the type of the bean to be proxied. So wrapping your bean into a FactoryBean might be a solution. FactoryBean has a getObjectType() method which you can implement properly. The additional effort should not be to big.



    • #3
      That's actually a duplicate.