Background
I'm new to spring. I'm using Spring MVC 3 and the spring tools suite by Springsource. I'm running a sample Spring Template they provide. I'm using Apache DBCP for my data source.
Problem
I have been able to inject beans using annotations but I am unable to get the container to obtain the datasource I have defined in my servlet-context.xml file. The contents are below. If I autowire my datasource then everywhere it is used I get a null pointer exception, indicating the dependency is not being injected. This works for any other class I try to autowire. I'm pretty sure it has something to do with the way I'm defining my bean in the XML file but I've seen several different ways of doing it so I'm not sure what's appropriate for my version.
<?xml version="1.0" encoding="UTF-8"?>
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<beans:bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<beans:property name="driverClassName" value="org.mysql.jdbc"/>
<beans:property name="url" value="jdbc:mysql://localhost:3306/mydb"/>
<beans:property name="username" value="root"/>
<beans:property name="password" value="admin"/>
</beans:bean>
<context:component-scan base-package="com.mycompany.myapp2" />
Part of the error returned by the server is
java.lang.NoClassDefFoundError: org/apache/commons/pool/KeyedObjectPoolFactory