Context initialization failed / Error creating bean with name 'org.springframework.security.filterChains'

Kappys

I have a problem and I do not fix it... I have a proyect WEB and I have a error withd Context initialization failed... I post the error and web.xml, etc...

2014-04-11 11:32:55,899 [ERROR, org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.filterChains': Cannot resolve reference to bean 'org.springframework.security.web.DefaultSecurityFilterChain#1' while setting bean property 'sourceList' with key [1]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#1': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler' while setting bean property 'authenticationSuccessHandler'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler' is defined
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:154)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:608)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.DefaultSecurityFilterChain#1': Cannot resolve reference to bean 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0' while setting constructor argument with key [2]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler' while setting bean property 'authenticationSuccessHandler'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler' is defined
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:154)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:615)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1045)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:949)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
    ... 26 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter#0': Cannot resolve reference to bean 'org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler' while setting bean property 'authenticationSuccessHandler'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler' is defined
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:329)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:107)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1387)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1128)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
    ... 40 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler' is defined
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:568)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1108)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:278)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:323)
    ... 50 more

this is the error when I start the server...

web.xml:

  <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/conf/spring/general.xml
            /WEB-INF/conf/spring/services.xml
            /WEB-INF/conf/spring/mybatis.xml
            /WEB-INF/conf/spring/security.xml 
        </param-value>
    </context-param>

    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/conf/log4j.properties</param-value>
    </context-param>

    <context-param>
        <param-name>webAppRootKey</param-name>
        <param-value>VENDING.root</param-value>
    </context-param>


    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>

    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

        <listener>
        <listener-class>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
    </listener>


    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>


    <listener>
        <listener-class>
            org.springframework.web.context.request.RequestContextListener
        </listener-class>
    </listener>

    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>springSecurityFilterChain</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>



  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>


    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/conf/spring/mvc.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
        <servlet-mapping>
            <servlet-name>dispatcher</servlet-name>
            <url-pattern>/</url-pattern>
        </servlet-mapping>

and now the security.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.1.xsd 
        http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd" >

    <global-method-security pre-post-annotations="enabled"></global-method-security>

    <http pattern="/resources-#{confProperties['resources.version']}/**" security="none" />

     <http pattern="/**" use-expressions="true" auto-config="false" 
            disable-url-rewriting="true">
        <intercept-url pattern="/" access="permitAll" />
        <intercept-url pattern="/home" access="permitAll" />
        <intercept-url pattern="/home/login" access="permitAll" />
        <intercept-url pattern="/**" access="isAuthenticated()" />

        <form-login authentication-failure-handler-ref="authenticationFailureHandler" 
                authentication-success-handler-ref="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler" 
                always-use-default-target="true" login-page="/home" 
                login-processing-url="${login.url}" username-parameter="${login.parameter.user}" 
                password-parameter="${login.parameter.password}" />

        <logout logout-url="/logout" success-handler-ref="userSaveLogoutSuccessHandler" 
                    delete-cookies="JSESSIONID" />

        <session-management session-fixation-protection="newSession" >
            <!-- <concurrency-control max-sessions="1" error-if-maximum-exceeded="true" /> -->
        </session-management>

        <remember-me services-ref="myRememberMeURLService" key="${autologin.remember.me.key}" />
    </http>

    <authentication-manager alias="authenticationManager">
        <authentication-provider user-service-ref="userDetailsService">
         <password-encoder hash="sha">
            <salt-source user-property="createdAt"/>
         </password-encoder>
        </authentication-provider>
    </authentication-manager>


    <beans:bean id="userDetailsService" class="com.logicart.vending.security.auth.service.UserDetailsAuthImpl">
        <beans:property name="operatorService" ref="operatorService"/>
    </beans:bean>

    <beans:bean id="userSaveLogoutSuccessHandler" 
        class="com.logicart.vending.security.auth.filter.handler.UserLogoutSuccessHandler" >
            <beans:property name="defaultTargetUrl" value="/home?logout=true" />
    </beans:bean>

    <beans:bean id="authenticationFailureHandler"
        class="com.logicart.vending.security.auth.filter.handler.UrlAuthenticationFailureHandler">
            <beans:property name="defaultFailureUrl" value="/home?failure=true"/>
    </beans:bean>

    <beans:bean id="myRememberMeURLService" class="com.logicart.vending.security.auth.service.AutoLoginURLRememberMeServices">
        <beans:property name="userDetailsService" ref="userDetailsService" />
        <beans:property name="configurator" ref="configurator" />
    </beans:bean>
</beans:beans>

I don't fount the error and thanks for yours help :)

this is my lib folder: enter image description here

Remi878

I think your error comes from :

authentication-success-handler-ref="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler"

Which should be a ref to a bean and not a class. Create that bean and link it in authentication-success-handler-ref by its id :

<beans:bean id="myAuthenticationSuccessHandler" class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
    <beans:property name="defaultTargetUrl" value="/" />
    <!-- After login, return to the last visited page -->
    <beans:property name="useReferer" value="true" />
</beans:bean>

... authentication-success-handler-ref="myAuthenticationSuccessHandler"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Spring Security error while creating bean with name 'org.springframework.security.filterChains'

From Dev

Error creating bean with name 'org.springframework.security.filterChains' Spring + Hibernate + UserDetailService

From Dev

Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name defined in class path resource

From Dev

Spring mvc + hibernate Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean

From Dev

ERROR: org.springframework.web.context.ContextLoader - Context initialization failed [context-security.xml]

From Dev

Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration':

From Dev

Error creating bean with name '...RedisHttpSessionConfiguration': Initialization of bean failed

From Dev

Spring Security 4.0.2- Multiple Authentication-manager -Error creating bean with name 'org.springframework.security.filterChainProxy'

From Dev

org.springframework.beans.factory.BeanCreationException: Error creating bean with name

From Dev

Error creating bean with name 'JobTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreat

From Dev

Spring ERROR - Context initialization failed: org.springframework.beans.factory.BeanCreationException

From Dev

Initialization of bean failed; nested exception is org.springframework.beans

From Dev

Context initialization failed due to org.springframework.core.ResolvableTypeProvider

From Dev

Error booting: org.springframework.beans.factory.BeanCreationException: Error creating bean with name

From Dev

getting error "org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'homeController'"

From Dev

Error booting: org.springframework.beans.factory.BeanCreationException: Error creating bean with name

From Dev

Error creating bean with name 'mySessionFactory' initialization of bean failed; nested exception is MalformedParameterizedTypeException

From Dev

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demoRestController'

From Dev

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MyController':

From Dev

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImpl'

From Dev

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdbcTemplate' defined in class path resource

From Dev

Spring Boot exported jar not working (org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory')

From Dev

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name userController : Unsatisfied dependency

From Dev

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demoRestController'

From Dev

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImpl'

From Dev

org.springframework.beans.factory.BeanCreationException: Error creating bean with name XXX defined in class path resource

From Dev

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actelService'

From Dev

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXX'

From Dev

Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myAppDao':

Related Related

  1. 1

    Spring Security error while creating bean with name 'org.springframework.security.filterChains'

  2. 2

    Error creating bean with name 'org.springframework.security.filterChains' Spring + Hibernate + UserDetailService

  3. 3

    Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name defined in class path resource

  4. 4

    Spring mvc + hibernate Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean

  5. 5

    ERROR: org.springframework.web.context.ContextLoader - Context initialization failed [context-security.xml]

  6. 6

    Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration':

  7. 7

    Error creating bean with name '...RedisHttpSessionConfiguration': Initialization of bean failed

  8. 8

    Spring Security 4.0.2- Multiple Authentication-manager -Error creating bean with name 'org.springframework.security.filterChainProxy'

  9. 9

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name

  10. 10

    Error creating bean with name 'JobTest': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreat

  11. 11

    Spring ERROR - Context initialization failed: org.springframework.beans.factory.BeanCreationException

  12. 12

    Initialization of bean failed; nested exception is org.springframework.beans

  13. 13

    Context initialization failed due to org.springframework.core.ResolvableTypeProvider

  14. 14

    Error booting: org.springframework.beans.factory.BeanCreationException: Error creating bean with name

  15. 15

    getting error "org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'homeController'"

  16. 16

    Error booting: org.springframework.beans.factory.BeanCreationException: Error creating bean with name

  17. 17

    Error creating bean with name 'mySessionFactory' initialization of bean failed; nested exception is MalformedParameterizedTypeException

  18. 18

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demoRestController'

  19. 19

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MyController':

  20. 20

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImpl'

  21. 21

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jdbcTemplate' defined in class path resource

  22. 22

    Spring Boot exported jar not working (org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory')

  23. 23

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name userController : Unsatisfied dependency

  24. 24

    org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'demoRestController'

  25. 25

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServiceImpl'

  26. 26

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name XXX defined in class path resource

  27. 27

    Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'actelService'

  28. 28

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXX'

  29. 29

    Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myAppDao':

HotTag

Archive