<?xml version="1.0" encoding="UTF-8"?> <!-- - Namespace-based OpenID configuration --> <b:beans xmlns="http://www.springframework.org/schema/security" xmlns:b="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"> <http> <intercept-url pattern="/**" access="ROLE_USER"/> <intercept-url pattern="/index.xhtml*" filters="none"/> <logout/> <openid-login login-page="/index.xhtml" authentication-failure-url="/index.xhtml?login_error=true"> <attribute-exchange> <openid-attribute name="email" type="http://schema.openid.net/contact/email" required="true" count="2"/> <openid-attribute name="name" type="http://schema.openid.net/namePerson/friendly" /> </attribute-exchange> </openid-login> <remember-me token-repository-ref="tokenRepo"/> </http> <b:bean id="tokenRepo" class="org.springframework.security.web.authentication.rememberme.InMemoryTokenRepositoryImpl" /> <authentication-manager alias="authenticationManager"/> <user-service id="userService"> <user name="http://user.myopenid.com/" authorities="ROLE_SUPERVISOR,ROLE_USER" /> </user-service> </b:beans>
和Web.xml文件是:
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <display-name>Spring Security OpenID Demo Application</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext-security.xml </param-value> </context-param> <context-param> <param-name>log4jConfigLocation</param-name> <param-value>/WEB-INF/classes/log4j.properties</param-value> </context-param> <context-param> <param-name>webAppRootKey</param-name> <param-value>openid.root</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> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class> </listener> <welcome-file-list> <welcome-file>faces/index.xhtml</welcome-file> </welcome-file-list> </web-app>
Clean和Build的应用程序是成功的,但当我尝试部署应用程序jetty 7给我以下错误:
SEVERE: Context initialization Failed
org.springframework.beans.factory.parsing.BeanDeFinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [07000
Offending resource: ServletContext resource [/WEB-INF/applicationContext-security.xml]
at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:80)
编辑
我试着添加3.0.2版本的Spring-Security,并得到这样:
Context initialization Failed
org.springframework.beans.factory.xml.XmlBeanDeFinitionStoreException: Line 13 in XML document from ServletContext resource [/WEB-INF/applicationContext-security.xml] is invalid;
nested exception is org.xml.sax.SAXParseException; lineNumber: 13; columnNumber: 11; cvc-complex-type.2.4.c: The matching wildcard is strict,but no declaration can be found for element ‘http’.
at org.springframework.beans.factory.xml.XmlBeanDeFinitionReader.doLoadBeanDeFinitions(XmlBeanDeFinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDeFinitionReader.loadBeanDeFinitions(XmlBeanDeFinitionReader.java:334
异常意味着security:xml namescape不能被spring的“解析器”处理。它们是NamespaceHandler接口的实现,因此您需要一个知道如何处理< security:tags的处理程序。这是SecurityNamespaceHandler位于spring-security-config
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。