2015-06-19 3 views
0

Я пытаюсь использовать модуль Spring Security, но получаю ошибку проверки XML в отношении файла xsd безопасности.Ошибка Spring при разрешении xsd-схемы

Это весна-security.xml:

<?xml version="1.0" encoding="UTF-8"?> 
<beans:beans xmlns="http://www.springframework.org/schema/mvc" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:tx="http://www.springframework.org/schema/tx" xmlns:security="http://www.springframework.org/schema/security" 
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd 
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd 
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd 
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd 
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd"> 



    <!-- Security....................................... --> 

    <security:http security="none" pattern="/resources/**"/> 
    <security:http auto-config="true" use-expressions="true" > 
     <security:intercept-url pattern="/admin/**" access="hasRole('Admin')" /> 
     <security:logout logout-success-url="/welcome" logout-url="/logout" /> 
     <security:form-login login-page="/login" 
      default-target-url="/welcome" 
      username-parameter="username" 
      password-parameter="hashPwd" 
      authentication-failure-url="/login?error" 
      /> 
    </security:http> 


    <security:authentication-manager> 
     <security:authentication-provider user-service-ref="controlloUtente"> 
     <security:password-encoder hash="bcrypt" /> 
     </security:authentication-provider> 
    </security:authentication-manager> 

</beans:beans> 

И это исключение я получаю (я, очевидно, проверить и файл существует!):

19/06/2015 12:32:38 - WARN - (SimpleSaxErrorHandler.java:48) - Ignored XML validation warning 
org.xml.sax.SAXParseException; lineNumber: 16; columnNumber: 58; schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/security/spring-security.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198) 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:99) 
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:433) 
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:347) 
    at com.sun.org.apache.xerces.internal.impl.xs.traversers.XSDHandler.reportSchemaErr(XSDHandler.java:4166) 

Я за прокси но я настроил его, а другой xsd был разрешен, поэтому я не знаю, что происходит.

+0

У вас есть Sping-security.jar в вашем buildpath? – Jens

+0

Конечно, у меня есть. Единственное, что вызывает у меня сомнения, это то, что все остальные файлы начинаются с '', в то время как этот с тегом ''. – lateralus

+0

Есть много вопросов об этом уже, проверьте свои версии зависимостей (также проверьте [this] (http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#ns-config) " Чтобы начать использовать пространство имен безопасности в контексте вашего приложения, вам нужно иметь баннер Spring-security-config на вашем пути к классам ») –

ответ

0

может быть, этот код поможет:

<?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:security="http://www.springframework.org/schema/security" 
xmlns:p="http://www.springframework.org/schema/p" 
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-3.1.xsd"> 

<security:http auto-config="true"> 

    <security:intercept-url pattern="/login.do" 
     access="IS_AUTHENTICATED_ANONYMOUSLY" /> 
    <security:intercept-url pattern="/logout.do" 
     access="IS_AUTHENTICATED_ANONYMOUSLY" /> 
    <security:intercept-url pattern="/fail2login.do" 
     access="IS_AUTHENTICATED_ANONYMOUSLY" /> 
    <security:intercept-url pattern="/json/*.do" 
     access="IS_AUTHENTICATED_ANONYMOUSLY" /> 

    <security:intercept-url pattern="/*" access="ROLE_ADMIN" /> 
    <security:form-login login-page="/login.do" 
     default-target-url="/home.do" authentication-failure-url="/fail2login.do" /> 

    <security:session-management> 
     <security:concurrency-control 
      max-sessions="1" /> 
    </security:session-management> 
    <security:logout logout-success-url="/logout.do" 
     delete-cookies="JSESSIONID" invalidate-session="true" /> 
</security:http> 

<security:authentication-manager> 
    <security:authentication-provider> 
     <security:jdbc-user-service 
      data-source-ref="dataSource" 
      users-by-username-query="select userName, password, status from User where userName=?" 
      authorities-by-username-query="select us.userName, ur.userRoleName from User us, UserRole ur 
      where ur.userName =? " /> 
    </security:authentication-provider> 
</security:authentication-manager>