java - Spring Security + CAS SSO AuthenticationManager -


i build java application using spring/spring-security. without cas-sso spring implementation application works fine. when implement cas configuration application , build it, @ startup following exception.

localhost-startstop-1 30.09.2015 13:34:48 warn   [org.springframework.web.context.support.xmlwebapplicationcontext] exception   encountered during context initialization - cancelling refresh attempt org.springframework.beans.factory.beancreationexception: error creating bean    name 'methodsecurityinterceptor' defined in class path resource [org/springframework/security/config/annotation/method/configuration/globalmethodsecurityconfiguration.class]: bean instantiation via factory method failed; nested exception org.springframework.beans.beaninstantiationexception: failed instantiate [org.aopalliance.intercept.methodinterceptor]: factory method 'methodsecurityinterceptor' threw exception; nested exception java.lang.illegalargumentexception: expecting find single bean type interface   org.springframework.security.authentication.authenticationmanager, found [org.springframework.security.config.authentication.authenticationmanagerfactorybean#0, org.springframework.security.authentication.providermanager#0, org.springframework.security.authenticationmanager] @ org.springframework.beans.factory.support.constructorresolver.instantiateusingfactorymethod(constructorresolver.java:599) ~[spring-beans-4.1.4.release.jar:4.1.4.release] @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.instantiateusingfactorymethod(abstractautowirecapablebeanfactory.java:1111) ~[spring-beans-4.1.4.release.jar:4.1.4.release] @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbeaninstance(abstractautowirecapablebeanfactory.java:1006) ~[spring-beans-4.1.4.release.jar:4.1.4.release] @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.docreatebean(abstractautowirecapablebeanfactory.java:504) ~[spring-beans-4.1.4.release.jar:4.1.4.release] @ org.springframework.beans.factory.support.abstractautowirecapablebeanfactory.createbean(abstractautowirecapablebeanfactory.java:476) ~[spring-beans-4.1.4.release.jar:4.1.4.release] @ org.springframework.beans.factory.support.abstractbeanfactory$1.getobject(abstractbeanfactory.java:303) ~[spring-beans-4.1.4.release.jar:4.1.4.release] @ org.springframework.beans.factory.support.defaultsingletonbeanregistry.getsingleton(defaultsingletonbeanregistry.java:230) ~[spring-beans-4.1.4.release.jar:4.1.4.release] @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:299) ~[spring-beans-4.1.4.release.jar:4.1.4.release] @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:194) ~[spring-beans-4.1.4.release.jar:4.1.4.release] @ org.springframework.beans.factory.support.defaultlistablebeanfactory.preinstantiatesingletons(defaultlistablebeanfactory.java:762) ~[spring-beans-4.1.4.release.jar:4.1.4.release] @ org.springframework.context.support.abstractapplicationcontext.finishbeanfactoryinitialization(abstractapplicationcontext.java:757) ~[spring-context-4.1.4.release.jar:4.1.4.release] @ org.springframework.context.support.abstractapplicationcontext.refresh(abstractapplicationcontext.java:480) ~[spring-context-4.1.4.release.jar:4.1.4.release] @ org.springframework.web.context.contextloader.configureandrefreshwebapplicationcontext(contextloader.java:403) [spring-web-4.1.4.release.jar:4.1.4.release] @ org.springframework.web.context.contextloader.initwebapplicationcontext(contextloader.java:306) [spring-web-4.1.4.release.jar:4.1.4.release] @ org.springframework.web.context.contextloaderlistener.contextinitialized(contextloaderlistener.java:106) [spring-web-4.1.4.release.jar:4.1.4.release] @ org.apache.catalina.core.standardcontext.listenerstart(standardcontext.java:4720) [tomcat-embed-core-8.0.18.jar:8.0.18] @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5154) [tomcat-embed-core-8.0.18.jar:8.0.18] @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150) [tomcat-embed-core-8.0.18.jar:8.0.18] @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1409) [tomcat-embed-core-8.0.18.jar:8.0.18] @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1399) [tomcat-embed-core-8.0.18.jar:8.0.18] @ java.util.concurrent.futuretask.run(futuretask.java:262) [na:1.7.0_60] @ java.util.concurrent.threadpoolexecutor.runworker(threadpoolexecutor.java:1145) [na:1.7.0_60] @ java.util.concurrent.threadpoolexecutor$worker.run(threadpoolexecutor.java:615) [na:1.7.0_60] @ java.lang.thread.run(thread.java:745) [na:1.7.0_60] caused by: org.springframework.beans.beaninstantiationexception: failed instantiate [org.aopalliance.intercept.methodinterceptor]: factory method 'methodsecurityinterceptor' threw exception; nested exception java.lang.illegalargumentexception: expecting find single bean type interface org.springframework.security.authentication.authenticationmanager, found [org.springframework.security.config.authentication.authenticationmanagerfactorybean#0, org.springframework.security.authentication.providermanager#0, org.springframework.security.authenticationmanager] @ org.springframework.beans.factory.support.simpleinstantiationstrategy.instantiate(simpleinstantiationstrategy.java:189) ~[spring-beans-4.1.4.release.jar:4.1.4.release] @ org.springframework.beans.factory.support.constructorresolver.instantiateusingfactorymethod(constructorresolver.java:588) ~[spring-beans-4.1.4.release.jar:4.1.4.release] ... 23 common frames omitted caused by: java.lang.illegalargumentexception: expecting find single bean type interface org.springframework.security.authentication.authenticationmanager, found [org.springframework.security.config.authentication.authenticationmanagerfactorybean#0, org.springframework.security.authentication.providermanager#0, org.springframework.security.authenticationmanager] @ org.springframework.util.assert.istrue(assert.java:65) ~[spring-core-4.1.4.release.jar:4.1.4.release] @ org.springframework.security.config.annotation.authentication.configuration.authenticationconfiguration.lazybean(authenticationconfiguration.java:112) ~[spring-security-config-3.2.5.release.jar:3.2.5.release] @ org.springframework.security.config.annotation.authentication.configuration.authenticationconfiguration.getauthenticationmangerbean(authenticationconfiguration.java:122) ~[spring-security-config-3.2.5.release.jar:3.2.5.release] @ org.springframework.security.config.annotation.authentication.configuration.authenticationconfiguration.getauthenticationmanager(authenticationconfiguration.java:81) ~[spring-security-config-3.2.5.release.jar:3.2.5.release] @ org.springframework.security.config.annotation.method.configuration.globalmethodsecurityconfiguration.authenticationmanager(globalmethodsecurityconfiguration.java:246) ~[spring-security-config-3.2.5.release.jar:3.2.5.release] @ org.springframework.security.config.annotation.method.configuration.globalmethodsecurityconfiguration.methodsecurityinterceptor(globalmethodsecurityconfiguration.java:117) ~[spring-security-config-3.2.5.release.jar:3.2.5.release] @ org.springframework.security.config.annotation.method.configuration.globalmethodsecurityconfiguration$$enhancerbyspringcglib$$9e9ddf83.cglib$methodsecurityinterceptor$7(<generated>) ~[spring-core-4.1.4.release.jar:3.2.5.release] @ org.springframework.security.config.annotation.method.configuration.globalmethodsecurityconfiguration$$enhancerbyspringcglib$$9e9ddf83$$fastclassbyspringcglib$$a8539286.invoke(<generated>) ~[spring-core-4.1.4.release.jar:3.2.5.release] @ org.springframework.cglib.proxy.methodproxy.invokesuper(methodproxy.java:228) ~[spring-core-4.1.4.release.jar:4.1.4.release] @ org.springframework.context.annotation.configurationclassenhancer$beanmethodinterceptor.intercept(configurationclassenhancer.java:309) ~[spring-context-4.1.4.release.jar:4.1.4.release] @ org.springframework.security.config.annotation.method.configuration.globalmethodsecurityconfiguration$$enhancerbyspringcglib$$9e9ddf83.methodsecurityinterceptor(<generated>) ~[spring-core-4.1.4.release.jar:3.2.5.release] @ sun.reflect.nativemethodaccessorimpl.invoke0(native method) ~[na:1.7.0_60] @ sun.reflect.nativemethodaccessorimpl.invoke(nativemethodaccessorimpl.java:57) ~[na:1.7.0_60] @ sun.reflect.delegatingmethodaccessorimpl.invoke(delegatingmethodaccessorimpl.java:43) ~[na:1.7.0_60] @ java.lang.reflect.method.invoke(method.java:606) ~[na:1.7.0_60] @ org.springframework.beans.factory.support.simpleinstantiationstrategy.instantiate(simpleinstantiationstrategy.java:162) ~[spring-beans-4.1.4.release.jar:4.1.4.release] ... 24 common frames omitted` 

my authenticationmanager declaration/configuration in spring-security-beans.xml is: <authentication-manager> <authentication-provider ref="casauthenticationprovider" /> </authentication-manager>

have hint me solve problem?

edit:

it's xml , java based configuration. in following spring-security-beans.xml:

<beans:beans xmlns="http://www.springframework.org/schema/security"        xmlns:beans="http://www.springframework.org/schema/beans"    xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"    xsi:schemalocation="http://www.springframework.org/schema/beans    http://www.springframework.org/schema/beans/spring-beans-3.2.xsd    http://www.springframework.org/schema/security    http://www.springframework.org/schema/security/spring-security-3.2.xsd">     <global-method-security secured-annotations="enabled" pre-post-annotations="enabled" />     <http auto-config="true" disable-url-rewriting="true" create-session="ifrequired">       <intercept-url pattern="/pages/*" access="role_ui_general, role_admin" />       <logout logout-success-url="/" invalidate-session="true" delete-cookies="jsessionid" />       <access-denied-handler ref="accessdeniedhandler" />    </http>     <authentication-manager alias="authenticationmanager">       <authentication-provider ref="casauthenticationprovider" />    </authentication-manager>     <beans:bean id="accessdeniedhandler" class="org.springframework.security.web.access.accessdeniedhandlerimpl">       <beans:property name="errorpage" value="/error_pages/403.jsp" />    </beans:bean>  </beans:beans> 

and cas configuration:

@configuration @enablewebsecurity @enableglobalmethodsecurity( securedenabled = true ) @controller public class securityconfig extends websecurityconfigureradapter {      @value( "${cas.service}" )     private string server_host;     @value( "${server.port}" )     private string server_port;     @value( "${cas.host}" )     private string cas_auth;     @value( "${cas.authpath}" )     private string cas_authpath;     @value( "${cas.logoutpath}" )     private string cas_logoutpath;      @override     protected void configure( final httpsecurity http ) throws exception {     http.authorizerequests().anyrequest().authenticated();     http.csrf().disable();     http.exceptionhandling().authenticationentrypoint( casauthenticationentrypoint() ).and().logout()     .logoutrequestmatcher( new antpathrequestmatcher( "/j_spring_cas_security_logout" ) ).and() //$non-nls-1$     .addfilter( casauthenticationfilter() )     .addfilterbefore( requestsinglesignoutfilter(), logoutfilter.class ); }  @override public void configure( final websecurity web ) throws exception {     web.ignoring().antmatchers( "/javax.faces.resource/**" ); //$non-nls-1$ }  @override protected void configure( final authenticationmanagerbuilder auth ) throws exception {     auth.authenticationprovider( casauthenticationprovider() ); }  @bean public casauthenticationprovider casauthenticationprovider() {     casauthenticationprovider casauthenticationprovider = new casauthenticationprovider();     casauthenticationprovider.setauthenticationuserdetailsservice( authenticationuserdetailsservice() );     casauthenticationprovider.setserviceproperties( serviceproperties() );     casauthenticationprovider.setticketvalidator( cas20serviceticketvalidator() );     casauthenticationprovider.setkey( "mc_auth" ); //$non-nls-1$     return casauthenticationprovider; }  @bean public authenticationuserdetailsservice authenticationuserdetailsservice() {     return new casauthenticationuserdetailsservice(); }  @bean public serviceproperties serviceproperties() {     serviceproperties serviceproperties = new serviceproperties();     serviceproperties.setservice( this.server_host + ":" + this.server_port + "/j_spring_cas_security_check" ); //$non-nls-1$ //$non-nls-2$     serviceproperties.setsendrenew( false );     return serviceproperties; }  @bean public cas20serviceticketvalidator cas20serviceticketvalidator() {     return new cas20serviceticketvalidator( this.cas_auth ); }  @bean public casauthenticationfilter casauthenticationfilter() throws exception {     casauthenticationfilter casauthenticationfilter = new casauthenticationfilter();     casauthenticationfilter.setauthenticationmanager( authenticationmanager() );     return casauthenticationfilter; }  @bean public casauthenticationentrypoint casauthenticationentrypoint() {     casauthenticationentrypoint casauthenticationentrypoint = new casauthenticationentrypoint();     casauthenticationentrypoint.setloginurl( this.cas_auth + this.cas_authpath );     casauthenticationentrypoint.setserviceproperties( serviceproperties() );     return casauthenticationentrypoint; }  @bean public logoutfilter requestsinglesignoutfilter() {     securitycontextlogouthandler logouthandler = new securitycontextlogouthandler();     logoutfilter logoutfilter = new logoutfilter( this.cas_auth + this.cas_logoutpath, logouthandler );     logoutfilter.setlogoutrequestmatcher( new antpathrequestmatcher( "/j_spring_cas_security_logout" ) ); //$non-nls-1$     return logoutfilter; }  @requestmapping( value = "/", method = requestmethod.get ) public string defaulturl( final httpsession session, final model model, final httpservletrequest request,         final httpservletresponse response ) {     return "redirect:/pages/main"; //$non-nls-1$ } 

you having 2 spring security configuration 1 xml , 1 through java configuration , both giving authenticationmanager bean . better remove either 1 of them , should work perfectly.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -