Announcement Announcement Module
Collapse
No announcement yet.
BeanCurrentlyInCreationException when if use AOP in Spring 2..0.7 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • BeanCurrentlyInCreationException when if use AOP in Spring 2..0.7

    Spring 2.0.7....

    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>
    Last edited by bglmmz; Oct 26th, 2007, 03:12 AM.

  • #2
    I have resolved this problem by BeanPostProcessor.

    Comment


    • #3
      Hello, I have the same problem, I can say as it has solved.

      Thank you

      Comment

      Working...
      X