Announcement Announcement Module
Collapse
No announcement yet.
why UnsatisfiedDependencyException ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • why UnsatisfiedDependencyException ?

    Hi All,

    Just wondering if you could throw light on why the “transactionManager” property on CsvFileDownloadRequestDao is NOT valid as complained by spring below ?

    I got the error while trying to run an unit test that extends AbstractTransactionalDataSourceSpringContextTests on java 1.4.x.

    The SpringConfig.xml file is below.

    Any and all help appreciated.

    Thank you,

    BR,
    ~A

    ========xxxxxxx===========xxxxxxxx======

    org.springframework.beans.factory.UnsatisfiedDepen dencyException: Error creating bean with name 'net.nike.oc.fulfiller.csvdownload.CsvFileDownload RequestDaoImplTest' defined in null: Unsatisfied dependency expressed through bean property 'transactionManager': Set this property value or disable dependency checking for this bean.

    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.dependencyCheck(Abstrac tAutowireCapableBeanFactory.java:830)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.populateBean(AbstractAu towireCapableBeanFactory.java:687)
    at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.autowireBeanProperties( AbstractAutowireCapableBeanFactory.java:171)
    at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.setUp(AbstractDependencyInjec tionSpringContextTests.java:123)
    at com.intellij.rt.execution.junit.JUnitStarter.main( JUnitStarter.java:40)

    ========xxxxxxx===========xxxxxxxx======

    <?xml version="1.0" encoding="UTF-8"?>
    <beans>
    <bean id="DataSource" class="org.springframework.jndi.JndiObjectFactoryB ean" lazy-init="true">
    <property name="jndiName">
    <value>dynamo:/atg/dynamo/service/jdbc/JTDataSource</value>
    </property>
    </bean>


    <bean id="CsvFileDownloadRequestDao" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean" lazy-init="true">
    <property name="transactionManager">
    <bean class="org.springframework.transaction.jta.JtaTran sactionManager" lazy-init="true"/>
    </property>

    <property name="target">
    <bean class="net.nike.oc.fulfiller.csvdownload.CsvFileDo wnloadRequestDaoImpl">
    <property name="jdbcTemplate">
    <bean class="org.springframework.jdbc.core.JdbcTemplate" autowire="byType"/>
    </property>
    </bean>
    </property>

    <property name="transactionAttributes">
    <props>
    <prop key="*">PROPAGATION_SUPPORTS</prop>
    </props>
    </property>
    </bean>

    <bean id="CsvFileDownloadRequestManager" class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean" lazy-init="true">
    <property name="transactionManager">
    <bean class="org.springframework.transaction.jta.JtaTran sactionManager" lazy-init="true"/>
    </property>

    <property name="target">
    <bean class="net.nike.oc.fulfiller.csvdownload.CsvFileDo wnloadRequestManagerImpl">
    <property name="csvFileDownloadRequestDao">
    <ref bean="CsvFileDownloadRequestDao"/>
    </property>
    </bean>
    </property>

    <property name="transactionAttributes">
    <props>
    <prop key="*">PROPAGATION_REQUIRED</prop>
    </props>
    </property>
    </bean>
    </beans>

  • #2
    The transactionmanager needs to be set as a dependency on your testcase, that is also what the complaint is about. You defined the transactionmanager as an inner bean so the testcase cannot locate it. Make it an outer bean and just reference it. Also your transactionmanager should be a singleton, you defined them as inner beans don't do this, make it a top level bean and simply supply a reference to the beans that need it.

    Next to that your dao's don't need to be wrapped in a transactional proxy, only your service (in your case the manager) needs to be transactional.

    Comment

    Working...
    X