Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6364547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:10:39+00:00 2026-05-25T00:10:39+00:00

I am using Spring framework mvc 3 + spring security 3. I would like

  • 0

I am using Spring framework mvc 3 + spring security 3.
I would like to enable role hierarchy in my spring security.
According to http://static.springsource.org/spring-security/site/docs/3.1.x/reference/authz-arch.html i should write

<bean id="roleVoter" class="org.springframework.security.access.vote.RoleHierarchyVoter">
    <constructor-arg ref="roleHierarchy" />
</bean>
<bean id="roleHierarchy"
    class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl">
<property name="hierarchy">
    ROLE_ADMIN > ROLE_STAFF
    ROLE_STAFF > ROLE_USER
    ROLE_USER > ROLE_GUEST
</property>
</bean>

But where should i put it? I tried to put it into my app-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">
    <http>
        <intercept-url pattern="/entryPost/**" access="ROLE_USER" requires-channel="https"/>
        <intercept-url pattern="/entryDelete/**" access="ROLE_ADMIN" requires-channel="https"/>
        <intercept-url pattern="/commentDelete/**" access="ROLE_ADMIN" requires-channel="https"/>
        <intercept-url pattern="/login" access="ROLE_ANONYMOUS" requires-channel="https"/>
        <form-login login-page="/login" default-target-url="/entryList/1" authentication-failure-url="/login?error=true" />
        <logout logout-success-url="/login" />
        <session-management>
            <concurrency-control max-sessions="1" />
        </session-management>
        <access-denied-handler error-page="/accessDenied"/>
    </http>
    <authentication-manager>
        <authentication-provider>
            <jdbc-user-service data-source-ref="dataSource"
            users-by-username-query="SELECT username,password,'true' as enabled FROM member WHERE username=?"
            authorities-by-username-query="SELECT member.username,role FROM member,memberRole WHERE member.username=? AND member.id=memberRole.member_id"/>
        </authentication-provider>
    </authentication-manager>
<bean id="roleVoter" class="org.springframework.security.access.vote.RoleHierarchyVoter">
    <constructor-arg ref="roleHierarchy" />
</bean>
<bean id="roleHierarchy" class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl">
    <property name="hierarchy">
        ROLE_ADMIN > ROLE_STAFF
        ROLE_STAFF > ROLE_USER
        ROLE_USER > ROLE_GUEST
    </property>
</bean>

But it doesn’t work: HTTP Status 404.

When I put it into app-servlet.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:mvc="http://www.springframework.org/schema/mvc" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:context="http://www.springframework.org/schema/context" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-3.0.xsd 
    http://www.springframework.org/schema/mvc 
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
    <context:component-scan base-package="rus.web"/>
    <bean id="entryValidator" class="rus.domain.EntryValidator"/>
    <bean id="commentValidator" class="rus.domain.CommentValidator"/>
    <mvc:annotation-driven/>
    <mvc:resources mapping="/resources/**" location="/resources/"/>
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <property name="suffix" value=".jsp"/>
    </bean>
    <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
        <property name="basename" value="messages"/>
    </bean>
    <!--<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
        <property name="defaultErrorView" value="error"/>
    </bean> -->

<bean id="roleVoter" class="org.springframework.security.access.vote.RoleHierarchyVoter">
    <constructor-arg ref="roleHierarchy" />
</bean>
<bean id="roleHierarchy" class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl">
    <property name="hierarchy">
        ROLE_ADMIN > ROLE_STAFF
        ROLE_STAFF > ROLE_USER
        ROLE_USER > ROLE_GUEST
    </property>
</bean>
</beans>

It throws exception:

org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 35 in XML document from ServletContext resource [/WEB-INF/rus-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.3: Element ‘property’ cannot have character [children], because the type’s content type is element-only.

org.xml.sax.SAXParseException: cvc-complex-type.2.3: Element ‘property’ cannot have character [children], because the type’s content type is element-only.

What should I do to solve this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:10:42+00:00Added an answer on May 25, 2026 at 12:10 am

    The documentation is wrong, this is not valid:

    <property name="hierarchy">
        ROLE_ADMIN > ROLE_STAFF
        ROLE_STAFF > ROLE_USER
        ROLE_USER > ROLE_GUEST
    </property>
    

    You need to wrap the contents inside <value>:

    <property name="hierarchy">
       <value>
          ROLE_ADMIN > ROLE_STAFF
          ROLE_STAFF > ROLE_USER
          ROLE_USER > ROLE_GUEST
       </value>
    </property>
    

    I suggest filing an issue on the SpringSource JIRA, asking them to fix the docs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to configure spring MVC application using Spring security the following way.
I'm building a MVC web application (using the Spring MVC framework), and I'm a
Almost every new Java-web-project is using a modern MVC-framework such as Struts or Spring
We're securing Mule services using the Spring Security Framework, and some of the services
I'm using tomcat 6, spring mvc 3.0.0 and spring security 3.0.0, and since the
I am java developer, (using Spring-MVC) never worked much on javascript, But I would
I am writing Web app in java using Spring Web MVC framework. Somehow validation
Environment: The application is using Spring Framework 2.5.6.SEC01 and iBatis 2.3.4.726. It is MVC
I am doing a web site using spring mvc framework. I want to do
I am using the Spring MVC framework with Hibernate. All of my controllers are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.