spring - No bean named 'springSecurityFilterChain' is defined in combination of Web.xml and Java Config -


here root application context class

@configuration @import({websecurityconfig.class}) public class contextconfig { } 

my websecurityconfig class

@configuration @enablewebsecurity public class websecurityconfig extends websecurityconfigureradapter{        @override        public void configure(websecurity web) throws exception {                web.ignoring().antmatchers("/resources/**");        }         @override        protected void configure(httpsecurity http) throws exception {                http.authorizerequests().antmatchers("/hello/**").permitall().anyrequest()                                .hasrole("user")                                .and()                                .formlogin()                                .permitall();        }         @override        protected void configure(authenticationmanagerbuilder auth) throws exception {                auth.inmemoryauthentication().withuser("user").password("password").roles("user")                                .and().withuser("admin").password("password").roles("user", "admin");        }         @autowired        public void configureglobal(authenticationmanagerbuilder auth) throws exception {            auth.inmemoryauthentication().withuser("user").password("password").roles("user");        } } 

my web.xml

<?xml version="1.0" encoding="utf-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">   <display-name>webtest</display-name>   <welcome-file-list>     <welcome-file>index.html</welcome-file>     <welcome-file>index.htm</welcome-file>     <welcome-file>index.jsp</welcome-file>     <welcome-file>default.html</welcome-file>     <welcome-file>default.htm</welcome-file>     <welcome-file>default.jsp</welcome-file>   </welcome-file-list>   <servlet>     <servlet-name>dispatcher</servlet-name>     <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>     <load-on-startup>1</load-on-startup>   </servlet>    <servlet-mapping>     <servlet-name>dispatcher</servlet-name>     <url-pattern>/</url-pattern>   </servlet-mapping>    <listener>     <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>   </listener>    <context-param>     <param-name>contextclass</param-name>     <param-value>org.springframework.web.context.support.annotationconfigwebapplicationcontext</param-value>   </context-param>   <context-param>     <param-name>contextconfiglocation</param-name>     <param-value>classpath:com/iis/webtest/config/contextconfig</param-value>     </context-param>   <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> </web-app> 

my dispatcher servlet xml

<?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans"  xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"   xmlns:context="http://www.springframework.org/schema/context"  xmlns:mvc="http://www.springframework.org/schema/mvc"  xsi:schemalocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  http://www.springframework.org/schema/mvc  http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd  http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.0.xsd">      <context:component-scan base-package="com.iis.*" annotation-config="true" ></context:component-scan>     <mvc:resources location="/test/" mapping="/**"/>         <mvc:default-servlet-handler/>       <mvc:annotation-driven/>  </beans> 

my pom.xml

<project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"     xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">     <modelversion>4.0.0</modelversion>      <groupid>com.iis</groupid>     <artifactid>webtest</artifactid>     <version>0.0.1-snapshot</version>     <packaging>war</packaging>      <name>webtest</name>     <url>http://maven.apache.org</url>      <properties>         <project.build.sourceencoding>utf-8</project.build.sourceencoding>     </properties>      <dependencies>         <dependency>             <groupid>junit</groupid>             <artifactid>junit</artifactid>             <version>3.8.1</version>             <scope>test</scope>         </dependency>         <!-- http://mvnrepository.com/artifact/javax/javaee-api -->         <dependency>             <groupid>javax</groupid>             <artifactid>javaee-api</artifactid>             <version>7.0</version>             <scope>provided</scope>         </dependency>         <!-- http://mvnrepository.com/artifact/org.springframework/spring-core -->         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-core</artifactid>             <version>4.3.0.release</version>         </dependency>         <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-webmvc</artifactid>             <version>4.3.0.release</version>         </dependency>         <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-core -->         <dependency>             <groupid>org.springframework.security</groupid>             <artifactid>spring-security-core</artifactid>             <version>4.1.1.release</version>         </dependency>         <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-web -->         <dependency>             <groupid>org.springframework.security</groupid>             <artifactid>spring-security-web</artifactid>             <version>4.1.1.release</version>         </dependency>         <!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-config -->         <dependency>             <groupid>org.springframework.security</groupid>             <artifactid>spring-security-config</artifactid>             <version>4.1.1.release</version>         </dependency>         <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->         <dependency>             <groupid>com.fasterxml.jackson.core</groupid>             <artifactid>jackson-core</artifactid>             <version>2.8.1</version>         </dependency>         <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->         <dependency>             <groupid>com.fasterxml.jackson.core</groupid>             <artifactid>jackson-databind</artifactid>             <version>2.8.1</version>         </dependency>     </dependencies>      <build>         <plugins>             <plugin>                 <groupid>org.apache.maven.plugins</groupid>                 <artifactid>maven-compiler-plugin</artifactid>                 <version>3.5.1</version>                 <configuration>                     <source>1.8</source>                     <target>1.8</target>                 </configuration>             </plugin>         </plugins>     </build> </project> 

i've tried xml configuration security.
same error.
i've searched solutions still unable find going wrong.

stacktrace aug 08, 2016 5:44:39 pm org.springframework.web.context.contextloader initwebapplicationcontext info: root webapplicationcontext: initialization completed in 212 ms aug 08, 2016 5:44:39 pm org.apache.catalina.core.standardcontext filterstart severe: exception starting filter springsecurityfilterchain org.springframework.beans.factory.nosuchbeandefinitionexception: no bean named 'springsecurityfilterchain' defined     @ org.springframework.beans.factory.support.defaultlistablebeanfactory.getbeandefinition(defaultlistablebeanfactory.java:701)     @ org.springframework.beans.factory.support.abstractbeanfactory.getmergedlocalbeandefinition(abstractbeanfactory.java:1180)     @ org.springframework.beans.factory.support.abstractbeanfactory.dogetbean(abstractbeanfactory.java:284)     @ org.springframework.beans.factory.support.abstractbeanfactory.getbean(abstractbeanfactory.java:202)     @ org.springframework.context.support.abstractapplicationcontext.getbean(abstractapplicationcontext.java:1082)     @ org.springframework.web.filter.delegatingfilterproxy.initdelegate(delegatingfilterproxy.java:326)     @ org.springframework.web.filter.delegatingfilterproxy.initfilterbean(delegatingfilterproxy.java:235)     @ org.springframework.web.filter.genericfilterbean.init(genericfilterbean.java:199)     @ org.apache.catalina.core.applicationfilterconfig.initfilter(applicationfilterconfig.java:279)     @ org.apache.catalina.core.applicationfilterconfig.getfilter(applicationfilterconfig.java:260)     @ org.apache.catalina.core.applicationfilterconfig.<init>(applicationfilterconfig.java:105)     @ org.apache.catalina.core.standardcontext.filterstart(standardcontext.java:4830)     @ org.apache.catalina.core.standardcontext.startinternal(standardcontext.java:5510)     @ org.apache.catalina.util.lifecyclebase.start(lifecyclebase.java:150)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1575)     @ org.apache.catalina.core.containerbase$startchild.call(containerbase.java:1565)     @ java.util.concurrent.futuretask.run(unknown source)     @ java.util.concurrent.threadpoolexecutor.runworker(unknown source)     @ java.util.concurrent.threadpoolexecutor$worker.run(unknown source)     @ java.lang.thread.run(unknown source)  aug 08, 2016 5:44:39 pm org.apache.catalina.core.standardcontext startinternal 

    <context-param>         <param-name>contextconfiglocation</param-name>         <param-value>classpath:com/iis/webtest/config/contextconfig, classpath:com/iis/webtest/config/websecurityconfig </param-value>         </context-param> 

use above code in web.xml(since need mention spring security **websecurityconfig** in web.xml ).


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -