Announcement Announcement Module
Collapse

JavaConfig forum decommissioned in favor of Core Container

As described at

http://static.springsource.org/sprin...fig/README.TXT

key features of the Spring JavaConfig project have been migrated into the core Spring Framework as of version 3.0.

Please see the Spring 3.0 documentation on @Configuration and @Bean support:

http://static.springsource.org/sprin...tml#beans-java

For any questions related to @Configuration classes and @Bean methods in Spring 3.0, please post in the dedicated 'Core Container' forum at

http://forum.springsource.org/forumdisplay.php?f=26
See more
See less
Cyclic bean references Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Cyclic bean references

    Hi,
    i have 3 daos PersonDAO, AddressDAO and CompanyDAO.
    PersonDAO has reference of AddressDAO.
    AddressDAO has reference of CompanyDAO.
    CompanyDAO has reference of PersonDAO .
    CompanyDAO has reference of AddressDAO .


    Please note that when i remove "CompanyDAO has reference of AddressDAO "
    the exception goes.


    I get the following exception:

    com.infosys.j2ee.subframework.persistence.dao.DAOS erviceException: There is an error at the time of creating the dao - PersonDAO
    at com.infosys.j2ee.subframework.persistence.dao.impl .SpringIbatisDAOService.getDAO(SpringIbatisDAOServ ice.java:303)
    at com.setlabs.PersonDAOTest.setUp(PersonDAOTest.java :51)
    at junit.framework.TestCase.runBare(TestCase.java:125 )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at junit.framework.TestResult.run(TestResult.java:109 )
    at junit.framework.TestCase.run(TestCase.java:118)
    at junit.framework.TestSuite.runTest(TestSuite.java:2 08)
    at junit.framework.TestSuite.run(TestSuite.java:203)
    at org.eclipse.jdt.internal.junit.runner.junit3.JUnit 3TestReference.run(JUnit3TestReference.java:128)
    at org.eclipse.jdt.internal.junit.runner.TestExecutio n.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:460)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(RemoteTestRunner.java:673)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.run(RemoteTestRunner.java:386)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(RemoteTestRunner.java:196)
    Caused by: org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'PersonDAOTarget' defined in class path resource [etc/spring-dao/RadienSpringDAOConfig.xml]: Cannot resolve reference to bean 'AddressDAO' while setting bean property 'addressDAO'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'AddressDAO' defined in class path resource [etc/spring-dao/RadienSpringDAOConfig.xml]: Cannot resolve reference to bean 'AddressDAOTarget' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'AddressDAOTarget' defined in class path resource [etc/spring-dao/RadienSpringDAOConfig.xml]: Cannot resolve reference to bean 'CompanyDAO' while setting bean property 'companyDAO'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'CompanyDAO' defined in class path resource [etc/spring-dao/RadienSpringDAOConfig.xml]: Cannot resolve reference to bean 'CompanyDAOTarget' while setting bean property 'target'; nested exception is org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'CompanyDAOTarget' defined in class path resource [etc/spring-dao/RadienSpringDAOConfig.xml]: Cannot resolve reference to bean 'AddressDAO' while setting bean property 'addressDAO'; nested exception is org.springframework.beans.factory.BeanCurrentlyInC reationException: Error creating bean with name 'AddressDAO': org.springframework.beans.factory.FactoryBeanNotIn itializedException: FactoryBean is not fully initialized yet


    ....not the complete stack trace..please refer the attached file for complete stack trace

    Spring Config File:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>

    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverM anagerDataSource">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
    <property name="url" value="jdbc:oracle:thin:@172.25.203.136:1526:PETST ORE"/>
    <property name="username" value="workshop"/>
    <property name="password" value="workshop"/>
    </bean>

    <!-- Transaction manager for a single JDBC DataSource -->
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager">
    <property name="dataSource" ref="dataSource"/>
    </bean>

    <!-- SqlMap setup for iBATIS Database Layer -->
    <bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClient FactoryBean">
    <property name="configLocation">
    <value>classpath:etc/sqlmap/SqlMapConfiq.xml</value>
    </property>
    <property name="dataSource" ref="dataSource"/>
    </bean>

    <bean id="PersonDAOTarget" class="com.setlabs.PersonDAOImpl">
    <property name="sqlMapClient" ref="sqlMapClient"/>
    <property name="addressDAO" ref="AddressDAO"/>
    </bean>
    <bean id="PersonDAO" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="target">
    <ref bean="PersonDAOTarget"/>
    </property>
    <property name="transactionManager" ref="transactionManager"/>
    <property name="transactionAttributes">
    <props>
    <prop key="save">PROPAGATION_REQUIRED,-SQLException</prop>
    <prop key="get*">PROPAGATION_REQUIRED,-SQLException</prop>
    <prop key="exists">PROPAGATION_REQUIRED,-SQLException</prop>
    <prop key="remove">PROPAGATION_REQUIRED,-SQLException</prop>
    <prop key="*">PROPAGATION_REQUIRED,-SQLException</prop>
    </props>
    </property>
    </bean>
    <bean id="AddressDAOTarget" class="com.setlabs.AddressDAOImpl">
    <property name="sqlMapClient" ref="sqlMapClient"/>
    <property name="companyDAO" ref="CompanyDAO"/>

    </bean>
    <bean id="AddressDAO" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="target">
    <ref bean="AddressDAOTarget"/>
    </property>
    <property name="transactionManager" ref="transactionManager"/>
    <property name="transactionAttributes">
    <props>
    <prop key="save">PROPAGATION_REQUIRED,-SQLException</prop>
    <prop key="get*">PROPAGATION_REQUIRED,-SQLException</prop>
    <prop key="exists">PROPAGATION_REQUIRED,-SQLException</prop>
    <prop key="remove">PROPAGATION_REQUIRED,-SQLException</prop>
    <prop key="*">PROPAGATION_REQUIRED,-SQLException</prop>
    </props>
    </property>
    </bean>
    <bean id="CompanyDAOTarget" class="com.setlabs.CompanyDAOImpl">
    <property name="sqlMapClient" ref="sqlMapClient"/>
    <property name="personDAO" ref="PersonDAO"/>
    <property name="addressDAO" ref="AddressDAO"/>

    </bean>
    <bean id="CompanyDAO" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
    <property name="target">
    <ref bean="CompanyDAOTarget"/>
    </property>
    <property name="transactionManager" ref="transactionManager"/>
    <property name="transactionAttributes">
    <props>
    <prop key="save">PROPAGATION_REQUIRED,-SQLException</prop>
    <prop key="get*">PROPAGATION_REQUIRED,-SQLException</prop>
    <prop key="exists">PROPAGATION_REQUIRED,-SQLException</prop>
    <prop key="remove">PROPAGATION_REQUIRED,-SQLException</prop>
    <prop key="*">PROPAGATION_REQUIRED,-SQLException</prop>
    </props>
    </property>
    </bean>

    </beans>


    Please help!!!

    ashish
Working...
X