Spring MVC + Tiles + Spring Security = The requested resource is not available

1.3k views Asked by At

I have to say the equation in the title drives me crazy. As soon as I add the DelegatingFilterProxy to web.xml I get the 'Error 404 The requested resource is not available'. Otherwise the web app works fine. I am sure the problem with my configuration but I just cannot figure out. Also I am a beginner in Spring Security...

web.xml

</web-app ...>
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/spring/security-context.xml
            /WEB-INF/SpringMVC-servlet.xml
        </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>

    <servlet>
        <servlet-name>SpringMVC</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>SpringMVC</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

security-context.xml

<b:beans xmlns:b="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/security" xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
    <http auto-config="true">
        <intercept-url pattern="/**" access="permitAll"/>
    </http>

    <authentication-manager>
        <authentication-provider>
            <user-service>
                <user name="user" password="password" authorities="ROLE_USER" />
                <user name="admin" password="password" authorities="ROLE_USER,ROLE_ADMIN"/>
            </user-service>
        </authentication-provider>
    </authentication-manager>
</b:beans>

SpringMVC-servlet.xml

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="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-3.1.xsd 
                        http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">

    <import resource="spring/management-app-context.xml"/>

    <mvc:annotation-driven/>

    <context:component-scan base-package="org.protneut.server.management.controller" />

    <mvc:resources mapping="/resources/**" location="/WEB-INF/resources/"/>
    <mvc:resources mapping="/jsp/**" location="/WEB-INF/jsp/"/>
    <mvc:default-servlet-handler />

    <bean id="viewResolver" class="org.springframework.web.servlet.view.tiles3.TilesViewResolver"/>

    <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
        <property name="definitions">
            <list>
                <value>/WEB-INF/tiles/tiles-definitions.xml</value>
            </list>
        </property>
    </bean> 
</beans>

So if I comment out the SpringSecurityFilterChain the app is working fine.
Also I cannot find any log in the app server's log file when trying to open the http://localhost:8080/management-app/administration/service/main (that is my URL)

Could somebody help me what is wrong?
Thank you in advance!

Regards,
V.

1

There are 1 answers

2
smoggers On BEST ANSWER

Change

<filter-name>SpringSecurityFilterChain</filter-name>

to

<filter-name>springSecurityFilterChain</filter-name>

in both filter-name tags