Announcement Announcement Module
Collapse
No announcement yet.
aop:config - BeanCurrentlyInCreationException Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • aop:config - BeanCurrentlyInCreationException

    I have business logic ClasssA and ClassB, they are circular reference, but I'm not to use constructor injection and stick to setter injection only.

    If I add the <aop:config> segment like below, thire's a BeanCurrentlyInCreationException like this:

    org.springframework.beans.factory.BeanCurrentlyInC reationException: Error creating bean with name 'channelBO': Bean with name 'channelBO' has been injected into other beans [MetaPageBO] in its raw version as part of a circular reference, but has eventually been wrapped (for example as part of auto-proxy creation). This means that said other beans do not use the final version of the bean. This is often the result of over-eager type matching - consider using 'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example.
    But If remove the <aop:config> segment, it works.

    Why? Could any one give me a hand?

    Code:
    ClassA {
       ClassB classB;
       setClassB();
       getClassB();  
    }
    
    ClassB {
       ClassA classA;
       setClassA();
       getClassA();  
    }
    The application context:
    Code:
    <aop:config proxy-target-class="true">
            <aop:pointcut id="txPointcut" expression="execution(*  Class*(..))"/>
            <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>
    </aop:config>
    
    <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="dataSource"/>
        </bean>
    
        <tx:advice id="txAdvice" transaction-manager="txManager">
            <tx:attributes>
                <tx:method name="add*" rollback-for="Exception"/>
                <tx:method name="insert*" rollback-for="Exception"/>
                <tx:method name="create*" rollback-for="Exception"/>
                <tx:method name="update*" rollback-for="Exception"/>
                <tx:method name="edit*" rollback-for="Exception"/>
                <tx:method name="*" read-only="true"/>
            </tx:attributes>
        </tx:advice>
    
    <bean id="classA" class="ClassA">
      <property name="classB" ref="classB"/>
    </bean>
    
    <bean id="classB" class="ClassB">
      <property name="classA" ref="classA"/>
    </bean>
    I need someone to help me. I think it is possible to solve them using BeanPostProcessor, but not how to do it.

    Thank you

  • #2
    Having the same problem. Any idea what can be done?

    Comment


    • #3
      Submitted JIRA issue

      I have submitted an issue in JIRA, so I guess we'll just have to wait and see what the gurus in charge have to say about it

      See the issue at:
      http://jira.springframework.org/browse/SPR-4566

      I have also added a comment about a possible work around that one can use, while waiting for (hopefully) a solution.

      Comment

      Working...
      X