John B
John B

Reputation: 32969

spring-security-web error loading context

I am attempting to use Web Security Expressions however when I load the context in my unit test I get org.xml.sax.SAXParseException: The markup declarations contained or pointed to by the document type declaration must be well-formed

My context file looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:sec="http://www.springframework.org/schema/security"
       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">

 // various beans here

 <sec:http use-expressions="true">
   <sec:intercept-url pattern="/admin*"
      access="hasRole('admin') and hasIpAddress('192.168.1.0/24')"/>
  </sec:http>

</beans>

If I don't include the <sec:http> tag I don't get the error. If I include just <sec:http/> I do get the error.

In my pom I have included:

<dependancy>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-web</artifactId>
    <version>3.0.5.RELEASE</version>
</dependancy>

Upvotes: 1

Views: 291

Answers (2)

John B
John B

Reputation: 32969

Turns out the schemas for spring security are in the spring-security-config jar. I needed that dependancy.

Upvotes: 0

Maksym Demidas
Maksym Demidas

Reputation: 7817

DTD files like this one

http://www.springframework.org/schema/security/spring-security-3.0.xsd

must be available for XML parser during each parse action. Make them available and the problem will go away.

Upvotes: 1

Related Questions