[main] WARN GenericApplicationContext:591 – Exception encountered during context initialization – cancelling refresh attempt: org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name ‘dataSource’ defined in class path resource [.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource

This is an issue faced if you have not dbcp jars in your classpath.

For maven the simple fix is to add the dependency to the pom.xml

		<dependency>
			<groupId>commons-dbcp</groupId>
			<artifactId>commons-dbcp</artifactId>
                        <version>1.4</version>
		</dependency>

Commons dbcp 2 is also avaliable.

		<dependency>
			<groupId>org.apache.commons</groupId>
			<artifactId>commons-dbcp2</artifactId>
			<version>2.9.0</version>
		</dependency>

But for this make sure that you update config to use

org.apache.commons.dbcp2.BasicDataSource

Leave a Comment