Announcement Announcement Module
Collapse
No announcement yet.
Can't access jsp anymore after setting up Spring security Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Can't access jsp anymore after setting up Spring security

    Hi,

    I recently added filters using spring security to spring mvc application wich worked before. The filters work great but spring can't find the .jsp files anymore. For instance, I have a jsp in /autoPA/WEB-INF/views/csvuploadform.jsp bound to a controller mapped to /upload. When I try to access /upload, I have to be authenticated. Once I am, I access to the controller (logs prove it) but I get a 404 and a No mapping found for HTTP request with URI [/autoPA/WEB-INF/views/csvuploadform.jsp] in DispatcherServlet with name 'SocialServlet' in logs.

    Since nothing changed in my code except the web.xml, I assume there is a trouble here, but I can't see where.

    Here is the aforementioned file :

    Code:
    <web-app 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"
    version="3.0">
    
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    
    <context-param>
        <param-name>spring.profiles.active</param-name>
        <param-value>dev</param-value>
    </context-param>
    
    <filter>
        <filter-name>encodingFilter</filter-name>
        <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
        <init-param>
            <param-name>encoding</param-name>
            <param-value>UTF-8</param-value>
        </init-param>
        <init-param>
            <param-name>forceEncoding</param-name>
            <param-value>true</param-value>
        </init-param>
    </filter>
    
    <filter-mapping>
        <filter-name>encodingFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <filter>
        <filter-name>hiddenHttpMethodFilter</filter-name>
        <filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
    </filter>
    
    <filter-mapping>
        <filter-name>hiddenHttpMethodFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <servlet>
        <servlet-name>SocialServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>
            /WEB-INF/social-context.xml         
            </param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
        <async-supported>true</async-supported>
    </servlet>
    <servlet-mapping>
        <servlet-name>SocialServlet</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
    
    <servlet>
        <servlet-name>RESTServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/restapi-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>RESTServlet</servlet-name>
        <url-pattern>/api/*</url-pattern>
    </servlet-mapping>
    
    <!-- Spring Security -->
    <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>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/applicationContext.xml,
            /WEB-INF/spring-security.xml
        </param-value>
    </context-param>
    And here is the spring-security.xml file :

    Code:
    <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.3.xsd">
    
    <http auto-config="true" use-expressions="true">
        <intercept-url pattern="/api/**" access="permitAll" />
        <intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
    </http>
    
    <authentication-manager>
        <authentication-provider>
            <user-service>
                <user name="test" password="test" authorities="ROLE_USER" />
            </user-service>
        </authentication-provider>
    </authentication-manager>
    And here is the social-context.html :

    Code:
        <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns:mvc="http://www.springframework.org/schema/mvc"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans"
        xsi:schemaLocation="
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
    
    
        <import resource="properties/socialProperties.xml" />
    
    
        <context:component-scan base-package="com.dynamease.web.social" />
        <context:annotation-config />
    
        <mvc:annotation-driven />
    
    
        <mvc:interceptors>
            <bean class="com.dynamease.entity.springsocialentities.UserInterceptor">
                <constructor-arg ref="usersConnectionRepository" />
            </bean>
        </mvc:interceptors>
    
        <bean
            class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="prefix" value="/WEB-INF/views/" />
            <property name="suffix" value=".jsp" />
        </bean>
    
        <!-- Allows users to sign-in with their provider accounts. -->
        <bean class="org.springframework.social.connect.web.ProviderSignInController">
            <constructor-arg ref="connectionFactoryLocator" />
            <constructor-arg ref="usersConnectionRepository" />
            <constructor-arg>
                <bean class="com.dynamease.entity.springsocialentities.SimpleSignInAdapter" />
            </constructor-arg>
        </bean>
    
    
        <mvc:view-controller path="/signin" />
        <mvc:view-controller path="/signout" />
        <mvc:view-controller path="/choice" />
    
        <!-- Upload -->
        <!-- <bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping" 
            /> -->
        <bean id="multipartResolver"
            class="org.springframework.web.multipart.commons.CommonsMultipartResolver" />
    
    
    </beans>
    Any ideas ?

  • #2
    I found the trouble : I replaced <url-pattern>/*</url-pattern> by <url-pattern>/</url-pattern> and it works.
    Last edited by fxmatthews; Jul 4th, 2013, 03:15 AM.

    Comment

    Working...
    X