Vivek

Wednesday 7 May 2014

Error creating bean with name 'centralAuthenticationService' While Configuring CAS for SSO functionality in Tomcat server.


 I got Error : creating bean with name 'centralAuthenticationService' , While Configuring CAS for SSO functionality.


SafeContextLoaderListener:
The Spring ContextLoaderListener we wrap threw on contextInitialized.
But for our having caught this error, the web application context would not have initialized.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'centralAuthenticationService' defined in ServletContext resource [/WEB-INF/spring-configuration/applicationContext.xml]: Cannot resolve reference to bean 'authenticationManager' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Cannot create inner bean 'org.jasig.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler#1453d72' of type [org.jasig.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler] while setting bean property 'authenticationHandlers' with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.jasig.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler#1453d72' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
.
.
.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.jasig.cas.adaptors.jdbc.SearchModeSearchDatabaseAuthenticationHandler#1453d72' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]: Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.commons.dbcp.BasicDataSource] for bean with name 'dataSource' defined in ServletContext resource [/WEB-INF/deployerConfigContext.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.commons.dbcp.BasicDataSource


Basically, If you are getting this error, reason is, you are missing some jars in your CAS server application's WEB-INF/lib/  directory related to creation of DataSource and ConnectionPooling.

Step 1.
Please collect below jars:
1. commons-collections-3.2.1.jar
2. commons-dbcp-1.4.jar
3. commons-pool-1.5.4.jar

Or similar version of Jars as per the CAS server.
While writing this, I have used:
where my cas server environment is: cas-server-3.5.2, Tomcat 7.x, Java 1.7 and Maven 2.1

Step 2.
Now Copy above jars to your CAS server's deployed location (e.g.  apache-tomcat-7.0.27/webapps/cas/WEB-INF/lib).

Step 3.
Before starting the tomcat, delete the  work and log folder inside the tomcat.

Step 4.

Test your application and check the logs, you should not get mentioned errors above. It should have been solved.