I\'m trying to add spring security to a regular JSF application. After repeated tries and I\'m failing with the following error on tomcat bring-up.
Here is the entir
I had this issue until I removed the project in question from the server's deployments (in JBoss Dev Studio, right-click the server and "Remove" the project in the Servers view), then did the following:
After this, just restart the server (in debug or run mode) by selecting the server, NOT the project itself.
This seemed to flush any previous settings/states/memory/whatever that was causing the issue, and I no longer got the error.
You need to add RequestContextListener
to your web.xml
what it does is namely bind the HTTP request object to the Thread that is servicing that request. This makes beans which are request- and session-scoped available further down the call chain.
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
I had the same problem, and it turned out there's an issue with the maven spring dependency chain. Dependency org.springframework spring-context was imported with version 3.0.5, whereas the overall spring version I was using was 3.2.2. Explicitly adding the dependency in my pom.xml solved it.
I detected the issue by using the -verbose:class jvm argument when running the server, and checking the jars classes in the XmlWebApplicationContext inheritance tree were loaded from.
use this dependecy in your pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
While removing the comments from a particular block in applicationcontext.xml, I missed out to remove --> "The end of comment". I didn't notice it and was as getting this error.
Later removed it and all was working fine!!
I see this code in applicationContext-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.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
You might be using incorrect spring version. For example, if you are using spring-xxx (spring-security-web.jar or spring-security-core.jar) version 3.1.xx in your library, this error will come out. Try change the code in applicationContext-security.xml
from 3.0.xsd to 3.1.xsd (the version number in the code must match back to the version sit in the library folder).
Hope this help.