https://github.com/Jasig/cas/issues/1691



From: [email protected] [mailto:[email protected]] On Behalf Of Nancy 
Snoke
Sent: Friday, April 22, 2016 11:39 AM
To: [email protected]
Subject: [cas-user] odd error setting up database auth handler cas 4.2.0



I am having an odd error when trying to add a 
queryDatabaseAuthenticationHandler to a CAS 4.2.0 server.   The error seems 
to indicate it is trying to set up 
queryAndEncodeDatabaseAuthenticationHandler as opposed to a 
queryDatabaseAuthenticationHandler.



I already have ldap set up, and am adding the database authentication 
handler.  Encase it matters I have written a custom password encoder, and 
the datasource is defined using spring profiles so that I can use a 
different ones for dev, test, and prod.



  Relevant from the deployerConfigContext.xml I have:



    <util:map id="authenticationHandlersResolvers">

        <entry key-ref="proxyAuthenticationHandler" 
value-ref="proxyPrincipalResolver" />

                                <entry key-ref="ldapAuthenticationHandler" 
value="#{null}" />

        <entry key-ref="jdbcAuthenticationHandler" 
value-ref="jdbcPrincipalResolver" />

    </util:map>



                <!-- Adding JDBC MyPolicy authentication Handlers -->

                <alias name="queryDatabaseAuthenticationHandler" 
alias="jdbcAuthenticationHandler" />

                <alias name="dataSource" alias="queryDatabaseDataSource" />

                <alias name="myPolicyPasswordEncoder" 
alias="passwordEncoder" />



                <beans profile="dev">

                                <bean id="dataSource"

                                                
class="com.mchange.v2.c3p0.ComboPooledDataSource"

                                                
p:driverClass="${database.driverClass}"

                                                p:jdbcUrl="${database.url}"

                                                p:user="${database.user}"

                                                
p:password="${database.password}"

                                                
p:initialPoolSize="${database.pool.minSize}"

                                                
p:minPoolSize="${database.pool.minSize}"

                                                
p:maxPoolSize="${database.pool.maxSize}"

                                                
p:maxIdleTimeExcessConnections="${database.pool.maxIdleTime}"

                                                
p:checkoutTimeout="${database.pool.maxWait}"

                                                
p:acquireIncrement="${database.pool.acquireIncrement}"

                                                
p:acquireRetryAttempts="${database.pool.acquireRetryAttempts}"

                                                
p:acquireRetryDelay="${database.pool.acquireRetryDelay}"

                                                
p:idleConnectionTestPeriod="${database.pool.idleConnectionTestPeriod}"

                                                
p:preferredTestQuery="${database.pool.connectionHealthQuery}" 
/>

                </beans>



                <beans profile="test,prod">

                                <bean id="dataSource" 
class="org.springframework.jndi.JndiObjectFactoryBean"

                                                
p:jndiName="java:comp/env/jdbc/genericDatabaseName 
" />

                </beans>



Then the error:



SEVERE: Exception sending context initialized event to listener instance of 
class org.springframework.web.context.ContextLoaderListener

org.springframework.beans.factory.UnsatisfiedDependencyException: Error 
creating bean with name 'queryAndEncodeDatabaseAuthenticationHandler' 
defined in URL 
[jar:file:/C:/Users/User/Desktop/Demo/Tools/apache-tomcat/webapps/auth-mypolicy/WEB-INF/lib/cas-server-support-jdbc-4.2.0.jar!/org/jasig/cas/adaptors/jdbc/QueryAndEncodeDatabaseAuthenticationHandler.class]:
 
Unsatisfied dependency expressed through constructor argument with index 0 
of type [javax.sql.DataSource]: : No qualifying bean of type 
[javax.sql.DataSource] found for dependency: expected at least 1 bean which 
qualifies as autowire candidate for this dependency. Dependency annotations: 
{@org.springframework.beans.factory.annotation.Qualifier(value=queryEncodeDatabaseDataSource)}
 
<mailto:%[email protected](value=queryEncodeDatabaseDataSource)%7d>
 
; nested exception is 
org.springframework.beans.factory.NoSuchBeanDefinitionException: No 
qualifying bean of type [javax.sql.DataSource] found for dependency: 
expected at least 1 bean which qualifies as autowire candidate for this 
dependency. Dependency annotations: 
{@org.springframework.beans.factory.annotation.Qualifier(value=queryEncodeDatabaseDataSource)}
 
<mailto:%[email protected](value=queryEncodeDatabaseDataSource)%7d>

                at 
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)

                at 
org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185)

                at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1143)

                at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1046)

                at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)

                at 
org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)

                at 
org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)

                at 
org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)

                at 
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)

                at 
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)

                at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)

                at 
org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:838)

                at 
org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:537)

                at 
org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:410)

                at 
org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306)

                at 
org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)

                at 
org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5003)

                at 
org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5517)

                at 
org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)

                at 
org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)

                at 
org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)

                at 
org.apache.catalina.core.StandardHost.addChild(StandardHost.java:652)

                at 
org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1095)

                at 
org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1930)

                at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)

                at java.util.concurrent.FutureTask.run(FutureTask.java:266)

                at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)

                at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

                at java.lang.Thread.run(Thread.java:745)

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: 
No qualifying bean of type [javax.sql.DataSource] found for dependency: 
expected at least 1 bean which qualifies as autowire candidate for this 
dependency. Dependency annotations: 
{@org.springframework.beans.factory.annotation.Qualifier(value=queryEncodeDatabaseDataSource)}
 
<mailto:%[email protected](value=queryEncodeDatabaseDataSource)%7d>

                at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)

                at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)

                at 
org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)

                at 
org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)

                at 
org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)

                ... 28 more



Any help is appreciated.



Thanks,

Nancy

-- 
You received this message because you are subscribed to the Google Groups 
"CAS Community" group.
To unsubscribe from this group and stop receiving emails from it, send an 
email to [email protected] 
<mailto:[email protected]> .
To post to this group, send email to [email protected] 
<mailto:[email protected]> .
Visit this group at https://groups.google.com/a/apereo.org/group/cas-user/.
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/ea4bee2605274320b1e37da768d30144%40TGI-EX13BE03.pgac.com
 
<https://groups.google.com/a/apereo.org/d/msgid/cas-user/ea4bee2605274320b1e37da768d30144%40TGI-EX13BE03.pgac.com?utm_medium=email&utm_source=footer>
 
.
For more options, visit https://groups.google.com/a/apereo.org/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/a/apereo.org/group/cas-user/.
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/fa3da2b2.000014dc.0000000b%40MMOAYYED.unicon.net.
For more options, visit https://groups.google.com/a/apereo.org/d/optout.

Reply via email to