Reputation: 9509
I am trying to include 'Spring security 3.2.0' into my existing web application which is built without spring and using Primefaces & EJB 3.
When I started with the basic configuration, and tried access the page displays without CSS styles. The below logs have some information about the path. I am not sure what I am missing.
Many thanks in advance.
Application Logs:-
05-02-2014 16:05:58 INFO DispatcherServlet:472 - FrameworkServlet 'spring': initialization completed in 831 ms
05-02-2014 16:05:58 DEBUG DispatcherServlet:141 - Servlet 'spring' configured successfully
05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/css/myapp.css]
05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/images/bg_myapp_header.gif]
05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/js/myapp.js]
05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/images/2_arial_white_myapp_bg.png]
05-02-2014 16:05:58 DEBUG DispatcherServlet:823 - DispatcherServlet with name 'spring' processing GET request for [/myapp/resources/images/logo.png]
05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/css/myapp.css
05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/js/myapp.js
05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:219 - Did not find handler method for [/resources/js/myapp.js]
05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/images/bg_myapp_header.gif
05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/images/2_arial_white_myapp_bg.png
05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:209 - Looking up handler method for path /resources/images/eba_logo.png
05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:219 - Did not find handler method for [/resources/images/2_arial_white_myapp_bg.png]
05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:219 - Did not find handler method for [/resources/images/bg_myapp_header.gif]
05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:219 - Did not find handler method for [/resources/css/myapp.css]
05-02-2014 16:05:58 WARN PageNotFound:1108 - No mapping found for HTTP request with URI [/myapp/resources/images/bg_myapp_header.gif] in DispatcherServlet with name 'spring'
05-02-2014 16:05:58 WARN PageNotFound:1108 - No mapping found for HTTP request with URI [/myapp/resources/images/2_arial_white_myapp_bg.png] in DispatcherServlet with name 'spring'
05-02-2014 16:05:58 WARN PageNotFound:1108 - No mapping found for HTTP request with URI [/myapp/resources/js/myapp.js] in DispatcherServlet with name 'spring'
05-02-2014 16:05:58 DEBUG RequestMappingHandlerMapping:219 - Did not find handler method for [/resources/images/logo.png]
05-02-2014 16:05:58 DEBUG HttpSessionSecurityContextRepository:300 - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
05-02-2014 16:05:58 DEBUG HttpSessionSecurityContextRepository:300 - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
05-02-2014 16:05:58 DEBUG HttpSessionSecurityContextRepository:300 - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession.
05-02-2014 16:05:58 WARN PageNotFound:1108 - No mapping found for HTTP request with URI [/myapp/resources/css/myapp.css] in DispatcherServlet with name 'spring'
05-02-2014 16:05:58 DEBUG DispatcherServlet:946 - Successfully completed request
05-02-2014 16:05:58 DEBUG DispatcherServlet:946 - Successfully completed request
05-02-2014 16:05:58 DEBUG DispatcherServlet:946 - Successfully completed request
05-02-2014 16:05:58 WARN PageNotFound:1108 - No mapping found for HTTP request with URI [/myapp/resources/images/logo.png] in DispatcherServlet with name 'spring'
spring-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/security http://www.springframework.org/schema/security/spring-security-3.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
<authentication-manager>
<authentication-provider>
<user-service>
<user name="jay" password="jay" authorities="ROLE_USER" />
</user-service>
</authentication-provider>
</authentication-manager>
<http pattern="/resources/css/**" security="none" />
<http pattern="/resources/images/**" security="none" />
<http pattern="/resources/js/**" security="none" />
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/faces/javax.faces.resource/**" access="permitAll" />
<intercept-url pattern="/faces/login.xhtml" access="permitAll" />
<intercept-url pattern="/faces/search.xhtml" access="permitAll" />
<intercept-url pattern="/faces/create.xhtml" access="hasRole('ROLE_USER')" />
<intercept-url pattern="/faces/update.xhtml" access="hasRole('ROLE_USER')" />
<intercept-url pattern="/**" access="permitAll" />
</http>
</beans:beans>
spring-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" 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.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
<mvc:annotation-driven />
<import resource="spring-security.xml" />
<mvc:resources location="/css/**" mapping="/resources/css/" />
<mvc:resources location="/images/**" mapping="/resources/images/" />
<mvc:resources location="/js/**" mapping="/resources/js/" />
</beans>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<!-- JSF configuration -->
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<!-- Filter for not to have local cache, instead load from server -->
<filter>
<filter-name>NoCacheFilter</filter-name>
<filter-class>com.jai.NoCacheFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>NoCacheFilter</filter-name>
<url-pattern>/faces/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>com.jai.HttpSessionChecker</listener-class>
</listener>
<!-- Primefaces theme -->
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>aristo</param-value>
</context-param>
<!-- Spring security configuration -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-security.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>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
</web-app>
Upvotes: 1
Views: 1322
Reputation: 83
I had the same problem , solved it by removing ** mark in (location="/css/**") and it worked for me ,define a folder to save your resource withing Web-content folder.
<mvc:resources mapping="/resources/**" location="/assets/"/>`
Folder structure application_name-->WebContent-->assets-->css
JSP CSS URL
<link rel="stylesheet" type="text/css" href="<c:url value="/resources/css/bootstrapStyles.css"/>"></link>
<script src="<c:url value="/resources/js/jquery-1.12.0.js" />"></script>
Upvotes: 0
Reputation: 750
what if you remove resource in path
<security:http pattern="/css/**" security="none"/>
<security:http pattern="/images/**" security="none"/>
<security:http pattern="/js/**" security="none"/>
Upvotes: 1