java - Spring security exceptions -


i creating first web-app spring security. save database user login, name, last name, password - login , password supposed used login.

when added login controller , spring security got errors.

severe:   exception while loading app : java.lang.illegalstateexception: containerbase.addchild: start: org.apache.catalina.lifecycleexception: org.springframework.beans.factory.beancreationexception: error creating bean name 'org.springframework.security.filterchains': cannot resolve reference bean 'org.springframework.security.web.defaultsecurityfilterchain#0' while setting bean property 'sourcelist' key [0]; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'org.springframework.security.web.defaultsecurityfilterchain#0': cannot resolve reference bean 'org.springframework.security.web.authentication.usernamepasswordauthenticationfilter#0' while setting constructor argument key [2]; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'org.springframework.security.web.authentication.usernamepasswordauthenticationfilter#0': cannot resolve reference bean 'org.springframework.security.authentication.providermanager#0' while setting bean property 'authenticationmanager'; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'org.springframework.security.authentication.providermanager#0': cannot resolve reference bean 'org.springframework.security.config.authentication.authenticationmanagerfactorybean#0' while setting constructor argument; nested exception org.springframework.beans.factory.beancreationexception: error creating bean name 'org.springframework.security.config.authentication.authenticationmanagerfactorybean#0': factorybean threw exception on object creation; nested exception org.springframework.beans.factory.nosuchbeandefinitionexception: no bean named 'org.springframework.security.authenticationmanager' defined: did forget add gobal <authentication-manager> element configuration (with child <authentication-provider> elements)? alternatively can use authentication-manager-ref attribute on <http> , <global-method-security> elements. 

before changings in pom file error was:

severe:   exception while loading app : java.lang.illegalstateexception: containerbase.addchild: start: org.apache.catalina.lifecycleexception: org.springframework.beans.factory.xml.xmlbeandefinitionstoreexception: line 19 in xml document servletcontext resource [/web-inf/security.xml] invalid; nested exception org.xml.sax.saxparseexception; linenumber: 19; columnnumber: 34; cvc-complex-type.2.4.c: matching wildcard strict, no declaration can found element 'http'. 

i not sure changed, think deleted added dependencies got first 1 error.

my pom file:

<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/maven-v4_0_0.xsd">      <modelversion>4.0.0</modelversion>     ...     <packaging>war</packaging>     ...     <url>http://maven.apache.org</url>      <repositories>         <repository>             <id>prime-repo</id>             <name>primefaces maven repository</name>             <url>http://repository.primefaces.org</url>             <layout>default</layout>         </repository>         <repository>             <url>http://repository.primefaces.org/</url>             <id>primefaces-maven-lib</id>             <layout>default</layout>             <name>repository library primefaces-maven-lib</name>         </repository>     </repositories>      <properties>         <spring.version>4.1.6.release</spring.version>         <springsecurity.version>3.2.5.release</springsecurity.version>         <maven.compiler.source>1.7</maven.compiler.source>         <maven.compiler.target>1.7</maven.compiler.target>     </properties>      <dependencies>          <!-- spring 3 dependencies -->         <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-core</artifactid>             <version>${spring.version}</version>         </dependency>          <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-context</artifactid>             <version>${spring.version}</version>         </dependency>             <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-web</artifactid>             <version>${spring.version}</version>         </dependency>          <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-tx</artifactid>             <version>${spring.version}</version>         </dependency>          <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-orm</artifactid>             <version>${spring.version}</version>         </dependency>          <dependency>             <groupid>org.springframework</groupid>             <artifactid>spring-test</artifactid>             <version>${spring.version}</version>         </dependency>          <!-- jsf library -->         <dependency>             <groupid>com.sun.faces</groupid>             <artifactid>jsf-api</artifactid>             <version>2.1.6</version>         </dependency>          <dependency>             <groupid>com.sun.faces</groupid>             <artifactid>jsf-impl</artifactid>             <version>2.1.6</version>         </dependency>          <dependency>             <groupid>javax.servlet</groupid>             <artifactid>jstl</artifactid>             <version>1.2</version>         </dependency>          <!-- primefaces library -->         <dependency>             <groupid>org.primefaces</groupid>             <artifactid>primefaces</artifactid>             <version>3.1.1</version>         </dependency>          <!-- hibernate library -->         <dependency>             <groupid>org.hibernate</groupid>             <artifactid>hibernate-core</artifactid>             <version>4.1.0.final</version>         </dependency>          <dependency>             <groupid>javassist</groupid>             <artifactid>javassist</artifactid>             <version>3.12.1.ga</version>         </dependency>            <!-- mysql java connector library -->         <dependency>             <groupid>mysql</groupid>             <artifactid>mysql-connector-java</artifactid>             <version>5.1.17</version>         </dependency>          <dependency>             <groupid>c3p0</groupid>             <artifactid>c3p0</artifactid>             <version>0.9.1.2</version>         </dependency>                      <!-- log4j library -->         <dependency>             <groupid>log4j</groupid>             <artifactid>log4j</artifactid>             <version>1.2.16</version>         </dependency>          <dependency>             <groupid>org.testng</groupid>             <artifactid>testng</artifactid>             <version>6.4</version>         </dependency>         <dependency>             <groupid>org.springframework.security</groupid>             <artifactid>spring-security-core</artifactid>             <version>${springsecurity.version}</version>             <type>jar</type>         </dependency>         <dependency>             <groupid>org.springframework.security</groupid>             <artifactid>spring-security-web</artifactid>             <version>${springsecurity.version}</version>             <type>jar</type>         </dependency>         <dependency>             <groupid>javax.servlet</groupid>             <artifactid>javax.servlet-api</artifactid>             <version>3.1.0</version>             <type>jar</type>         </dependency>         <dependency>             <groupid>org.springframework.security</groupid>             <artifactid>spring-security-config</artifactid>             <version>${springsecurity.version}</version>         </dependency>      </dependencies>     </project> 

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"           xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"           xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"           id="webapp_id"           version="2.5">      <display-name>...</display-name>      <!-- spring context configuration' s path definition -->     <context-param>         <param-name>contextconfiglocation</param-name>         <param-value>             /web-inf/applicationcontext.xml             /web-inf/security.xml         </param-value>     </context-param>      <!-- bootstrap listener start , shut down spring's root webapplicationcontext. registered servlet container -->     <listener>         <listener-class>             org.springframework.web.context.contextloaderlistener         </listener-class>     </listener>     <listener>         <listener-class>             org.springframework.web.context.request.requestcontextlistener         </listener-class>     </listener>      <!-- enable spring security -->     <filter>         <filter-name>springsecurityfilterchain</filter-name>         <filter-class>org.springframework.web.filter.delegatingfilterproxy</filter-class>     </filter>      <!-- allow login pages jsf redirects security check,     therefore have add forward entry here -->     <filter-mapping>         <filter-name>springsecurityfilterchain</filter-name>         <url-pattern>/*</url-pattern>         <dispatcher>forward</dispatcher>         <dispatcher>request</dispatcher>     </filter-mapping>      <!-- project stage level -->     <context-param>         <param-name>javax.faces.project_stage</param-name>         <param-value>development</param-value>     </context-param>      <!-- welcome page -->     <welcome-file-list>         <welcome-file>pages/index.xhtml</welcome-file>     </welcome-file-list>      <!-- jsf servlet defined container -->     <servlet>         <servlet-name>faces servlet</servlet-name>         <servlet-class>javax.faces.webapp.facesservlet</servlet-class>         <load-on-startup>1</load-on-startup>     </servlet>      <!-- mapping servlet , url http requests. -->     <servlet-mapping>         <servlet-name>faces servlet</servlet-name>         <url-pattern>*.jsf</url-pattern>     </servlet-mapping>     <servlet-mapping>         <servlet-name>faces servlet</servlet-name>         <url-pattern>*.faces</url-pattern>     </servlet-mapping>     <servlet-mapping>         <servlet-name>faces servlet</servlet-name>         <url-pattern>*.xhtml</url-pattern>     </servlet-mapping>   </web-app> 

security.xml

<?xml version="1.0" encoding="utf-8"?> <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.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">      <http use-expressions="true">         <!-- custom login page -->         <form-login login-page="/pages/login.jsf" />             </http>  </beans:beans> 

how fix this?

try add versions xsi:schemalocation in security.xml,

xsi:schemalocation="http://www.springframework.org/schema/beans         http://www.springframework.org/schema/beans/spring-beans-3.1.xsd         http://www.springframework.org/schema/context          http://www.springframework.org/schema/context/spring-context-3.1.xsd         http://www.springframework.org/schema/security         http://www.springframework.org/schema/security/spring-security-3.1.xsd"> 

i hope helpfull


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -