Surendra
Surendra

Reputation: 129

java.lang.IllegalStateException: Failed to load ApplicationContext

While Running a J Unit Test Case I am getting the Following Error :

java.lang.IllegalStateException: Failed to load ApplicationContext  Caused by: 
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean 
named 'dataSource' is defined

I Have Define the DataSource As "com.mchange.v2.c3p0.ComboPooledDataSource" in .xml file.

What may the reason Please help.

Upvotes: 3

Views: 25943

Answers (1)

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340953

Is your bean defined exactly as follows (your exception suggests that beans' id matters)?

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" ...

Also are you sure this XML file is picked up by JUnit? Add some bogus characters at the beginning of the file, if the test fails while parsing the file, it's OK. If you get the same error - the file isn't even parsed by JUnit runner.

Upvotes: 8

Related Questions