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

  • AbstractTransactionalDataSourceSpringContextTests UnsatisfiedDependencyException

    Sorry if this is a repeat question.
    I am new to Spring (I love it), I am trying the Appfuse application. I am using Eclipse3.1.2, have src, test folders. Spring-Version: 1.2.6. The test classes are in test src. my dao classes are in src folder. my context files are in WEB-INF folder

    Instead of Person, I have Client and I am getting the following error when trying to run the ClientDaoTest:

    org.springframework.beans.factory.UnsatisfiedDepen dencyException: Error creating bean with name 'org.appfuse.test.dao.ClientDaoTest' defined in null: Unsatisfied dependency expressed through bean property 'clientDao': set this property value or disable dependency checking for this bean
    at AutowireCapableBeanFactory.checkDependencies(Abstr
    at AutowireCapableBeanFactory.populateBean(AbstractAu
    at AutowireCapableBeanFactory.autowireBeanProperties(
    at org.springframework.test.AbstractDependencyInjecti onSpringContextTests.setUp(AbstractDependencyInjec
    at junit.framework.TestCase.runBare( )
    at junit.framework.TestResult$1.protect(TestResult.ja va:106)
    at junit.framework.TestResult.runProtected(TestResult .java:124)
    at )
    at junit.framework.TestSuite.runTest( 08)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.runTests(
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRu nner.main(

    Here is my applicationContext-hibernate.xml:

    <!-- ClientDao: Hibernate implementation -->
    <bean id="clientDao" class="org.appfuse.dao.hibernate.ClientDaoHibernat e">
    <property name="sessionFactory" ref="sessionFactory"/>

    Here is my ClientDaoTest:

    public class ClientDaoTest extends BaseDaoTestCase {

    protected Client client = null;
    protected ClientDao dao = null;

    public void setClientDao(ClientDao dao){
    this.dao = dao;

    public void testGetClient() throws Exception{

    client = new Client();
    client.setEmail("[email protected]");

    assertEquals(client.getFirstName(), "A");

    Here is my BaseDaoTestCase

    public abstract class BaseDaoTestCase extends AbstractTransactionalDataSourceSpringContextTests {

    protected final Log log = LogFactory.getLog(getClass());
    protected ResourceBundle rb;

    protected String[] getConfigLocations() {
    return new String [] {"classpath*:/WEB-INF/applicationContext-*.xml",

    public BaseDaoTestCase() {
    // Since a ResourceBundle is not required for each class, just
    // do a simple check to see if one exists
    String className = this.getClass().getName();

    try {
    rb = ResourceBundle.getBundle(className);
    } catch (MissingResourceException mre) {
    //log.warn("No resource bundle found for: " + className);

    * Utility method to populate a javabean-style object with values
    * from a Properties file
    * @param obj
    * @return Object populated object
    * @throws Exception
    protected Object populate(Object obj) throws Exception {
    // loop through all the beans methods and set its properties from
    // its .properties file
    Map map = new HashMap();

    for (Enumeration keys = rb.getKeys(); keys.hasMoreElements() {
    String key = (String) keys.nextElement();
    map.put(key, rb.getString(key));

    BeanUtils.copyProperties(obj, map);

    return obj;

    Any ideas.
    Thank you very much.

  • #2
    I found the problem. It was not reading the context files which were located under WEB-INF folder. I moved to src folder and boom the error disappeared.