Announcement Announcement Module
No announcement yet.
Migration from TransactionProxyFactoryBean to Spring 2.0 transaction advice problem Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Migration from TransactionProxyFactoryBean to Spring 2.0 transaction advice problem

    I decided to go for Spring 2.0 transaction advice as I have quite a lot of transactional beans.
    So I just removed all my interceptor to replace them with a nice <tx:advice>

    With the exact same config, I get a
    BeanCurrentlyInCreationException: Error creating bean with name
    'financialService': Bean with name 'financialService' has been injected into
    other beans [dossierFormationService, imputationDotationSubService] 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.
    I found only this thread referencing the same pb: Using DefaultIntroductionAdvisor and tx:advice causing BeanCurrentlyInCreationException

    The doc about Circular Dependencies is not very helpful either (I already stick to setter injection only).

    Any lead welcome :-)


  • #2
    I'm actually still using TransactionProxyFactoryBean and instead using bean inheritence to cut down the XML. Regardless, is it possible to see the problematic XML? Are you using autoproxying?


    • #3
      Hi Karl, thanks for the answer.
      I've been considering bean inheritance as well, but I'm less familiar and I though advice were an elegant way to get things done.

      This is an extract of the concerned code:
       <!-- the transactional advice (i.e. what 'happens'; see the <aop:advisor/> bean below) -->
          <tx:advice id="txAdvice" transaction-manager="transactionManager">
              <!-- the transactional semantics... -->
                  <!-- all methods starting with 'get' are read-only -->
                  <!--<tx:method name="get*" read-only="true"/>-->
                  <!-- methods that use the default transaction settings (see below) -->
                  <tx:method name="create*" rollback-for="EmptyDotationException,GenerateNumeroDossierFormationException"/>
                  <tx:method name="update*" rollback-for="EmptyDotationException"/>
                  <tx:method name="delete*"/>
                  <tx:method name="activate*"/>
                  <tx:method name="deactivate*"/>
                  <tx:method name="archive*"/>
                  <tx:method name="print*"/>
                  <tx:method name="getNextCourrierReference"/>
                  <tx:method name="sendContracts"/>
                  <tx:method name="mutualisation*" rollback-for="DAOException"/>
                  <tx:method name="fireGenerateInterfaceComptableJob"/>
                  <tx:method name="fireImportCotisationFileJob"/>
                  <tx:method name="fireImportRecusFileJob"/>
                  <tx:method name="*" propagation="NEVER"/>
          <!-- ensure that the above transactional advice runs for any execution
              of an operation defined by the FooService interface -->
              <aop:pointcut id="serviceOperation" expression="execution(* org.xx.*.service.*Service.*(..))"/>
              <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation"/>
          <bean id="operationComptableEngagement" class="org.xx.operationcomptable.service.OperationComptableEngagement" scope="singleton">
              <property name="commonDAO" ref="commonDAOHibernate"/>
              <property name="financialService">
                  <ref local="financialService"/>
          <bean id="financialService" class="org.xx.common.service.FinancialService" scope="singleton">
              <property name="commonDAO" ref="commonDAOHibernate"/>
              <property name="serviceMediator">
                  <ref local="serviceMediator"/>
          <bean id="dossierFormationService" class="org.xx.dossierformation.service.DossierFormationServiceImpl" scope="singleton">
              <property name="commonDAO" ref="commonDAOHibernate"/>
              <property name="dossierFormationDAO" ref="dossierFormationDAOHibernate"/>
              <property name="contentieuxDAO" ref="contentieuxDAOHibernate"/>
              <property name="globalProperties">
                  <ref local="globalProperties"/>
              <property name="financialService">
                  <ref local="financialService"/>
              <property name="serviceMediator">
                  <ref local="serviceMediator"/>
              <property name="commonBatchDAO" ref="commonBatchDAOJdbc"/>
          <bean id="imputationDotationSubService" class="org.xx.dotation.service.ImputationDotationSubService" scope="singleton">
              <property name="commonDAO" ref="commonDAOHibernate"/>
              <property name="dotationDAO" ref="dotationDAOHibernate"/>
              <property name="financialService">
                  <ref local="financialService"/>
          <!-- ServiceMediator, allows interaction between services -->
          <bean id="serviceMediator" class="org.xx.common.service.ServiceMediator" scope="singleton">
              <property name="adherentService">
                  <ref local="adherentService"/>
              <property name="dossierFormationService">
                  <ref local="dossierFormationService"/>
              <property name="dossierAdherentService">
                  <ref local="dossierAdherentService"/>
              <property name="courrierModuleFacade">
                  <ref local="courrierModuleCrystal"/>
              <property name="dotationService">
                  <ref local="dotationService"/>
              <property name="courrierService">
                  <ref local="courrierService"/>
              <property name="operationComptableService">
                  <ref local="operationComptableService"/>
              <property name="engagementRemboursementService">
                  <ref local="engagementRemboursementService"/>
              <property name="contractService">
                  <ref local="contractService"/>
      I'm interested to see your bean inheritance examples anyway.
      Last edited by Jean; Jun 3rd, 2008, 03:58 AM.


      • #4
        Is that your complete applicationContext.xml? As for my examples, I'd have a look at the thread I posted it's got better examples on it.


        • #5
          I found the example. didn't look down the page the first time.
          I'm pretty sure it should work, as it used to with TransactionProxyFactoryBean. But why the hell this doesn't work anymore with <tx:advice> style???

          I have to attach the full code, it's too long to fit in the page. And I had to compress it as well... Attachement doesn't support XML it seems.


          • #6
            Error creating bean with name 'financialService': Bean with name 'financialService' has been injected into other beans [dossierFormationService, imputationDotationSubService] in its raw version as part of a circular reference, but has eventually been wrapped (for example as part of auto-proxy creation)

            Is there a way to order the instantiation of the proxy? Is it possible to force this 'financialService' proxy to be instantiated before hand?consider using

            'getBeanNamesOfType' with the 'allowEagerInit' flag turned off, for example
            Can this be of use in this case?