GoogleSearchBox

Custom Search

Thursday, June 6, 2013

Error creating bean with name 'centralAuthenticationService' While Configuring CAS for SSO functionality

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 6.x, Java 1.6 and Maven 2.1

Step 2.
Now Copy above jars to your CAS server's Workspace Build Location (e.g. /opt/cas-workspace/local-cas/src/main/webapp/WEB-INF/lib/ )   Or directly to  your CAS server's deployed location (e.g.  /usr/local/apache-tomcat-6.0.37/webapps/cas/WEB-INF/lib).

Difference between these two location is that, the later pics jars from the former's path while build.
So if you put the jar directly on later path, chances are that when you do a new build those jars will be deleted, as you have not put those jars in the source build location (the Former directory location).
If you are following CAS Maven2 WAR Overlay way to build the CAS.

Step 3.
Now do a maven build (assuming you are in your workspace home build location  e.g. /opt/cas-workspace/local-cas/      where you have the  pom.xml  file):
$ mvn clean package 

Step 4.

Before starting the tomcat, delete the  "cas" directory (war archived) created at /opt/cas-workspace/local-cas/src/main/webapp/  (This is actually my Path ;) ) or your similar path as per your project settings.
$ rm -rf cas

Step 5.

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


No comments:

Post a Comment