3

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.

2
  • Please show your test class and your xml config. Commented Oct 21, 2011 at 10:52
  • You have probably not included all of the required xml files in your context. Commented Oct 21, 2011 at 10:59

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.