Announcement Announcement Module
Collapse
No announcement yet.
Spring Security beginner’s question. Build failed Page Title Module
Move Remove Collapse
This topic is closed
X
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Security beginner’s question. Build failed

    Hello,

    I downloaded all jar files for Spring Security 3.0 and added them to my lib folder in Netbeans 6.8. Then i added Spring framework to my web application and tried to modify applicationContext.xml as given in the pdf that shipped with Spring Security. This is it's code :-

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:security="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">
    
        <http auto-config='true'>
            <intercept-url pattern="/**" access="ROLE_USER" />
        </http>
    
         <authentication-manager>
       <authentication-provider>
         <user-service>
           <user name="jimi" password="jimispassword" authorities="ROLE_USER, ROLE_ADMIN" />
           <user name="bob" password="bobspassword" authorities="ROLE_USER" />
         </user-service>
       </authentication-provider>
     </authentication-manager>
    
    
        <!--bean id="propertyConfigurer"
              class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
              p:location="/WEB-INF/jdbc.properties" />
    
        <bean id="dataSource"
              class="org.springframework.jdbc.datasource.DriverManagerDataSource"
              p:driverClassName="${jdbc.driverClassName}"
              p:url="${jdbc.url}"
              p:username="${jdbc.username}"
              p:password="${jdbc.password}" /-->
    
        <!-- ADD PERSISTENCE SUPPORT HERE (jpa, hibernate, etc) -->
    
    </beans>

    This is my web.xml :-

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
        <listener>
            <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
        </listener>
        <servlet>
            <servlet-name>dispatcher</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <load-on-startup>2</load-on-startup>
        </servlet>
        <servlet-mapping>
            <servlet-name>dispatcher</servlet-name>
            <url-pattern>*.htm</url-pattern>
        </servlet-mapping>
        <session-config>
            <session-timeout>
                30
            </session-timeout>
        </session-config>
        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/applicationContext.xml</param-value>
        </context-param>
    
        <listener>
            <listener-class>
                org.springframework.web.context.ContextLoaderListener
            </listener-class>
        </listener>
        <listener>
            <listener-class>
                org.springframework.web.context.request.RequestContextListener
            </listener-class>
        </listener>
    
    
        <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>
        <welcome-file-list>
            <welcome-file>redirect.jsp</welcome-file>
        </welcome-file-list>
    </web-app>
    My web application doesn't compile. I simply keep getting build failed. This is the stacktrace :-

    Code:
    INFO: Refreshing o[email protected]108026d: display name [Root WebApplicationContext]; startup date [Mon Mar 22 18:23:37 PDT 2010]; root of context hierarchy
    INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/applicationContext.xml]
    SEVERE: Context initialization failed
    org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 11 in XML document from ServletContext resource [/WEB-INF/applicationContext.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'http'. One of '{"http://www.springframework.org/schema/beans":description, "http://www.springframework.org/schema/beans":import, "http://www.springframework.org/schema/beans":alias, "http://www.springframework.org/schema/beans":bean, WC[##other:"http://www.springframework.org/schema/beans"]}' is expected.

  • #2
    Your XML is invalid. You need to use the prefix "security" on the security namespace elements since you are using "beans" as the default namespace. Please use one of the sample applications as a starting point.

    Comment


    • #3
      Use following namespace.

      <beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:util="http://www.springframework.org/schema/util"
      xmlns:security="http://www.springframework.org/schema/security"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
      http://www.springframework.org/schem...-beans-2.5.xsd
      http://www.springframework.org/schema/util
      http://www.springframework.org/schem...g-util-2.5.xsd
      http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-2.0.xsd">

      Comment


      • #4
        Originally posted by sony_notes View Post
        Use following namespace.
        No, that's not correct. The original poster is using Spring Security 3.0, which won't work with the 2.0 namespace schema.

        Comment

        Working...
        X