In my Spring Web Application project I've already configured an mvc:resources tag in order to exclude CSS, JS, images ... from DispatcherServlet mapping
Now I need to exclude also a foobar.txt and is placed under /webapp directory like the other static resources but ... It doesn't work.
Here my code snippet
<mvc:resources mapping="/assets/**" location="/assets/" />
<mvc:resources mapping="/foobar.txt" location="/foobar.txt" />
my folder structure is:
/webapp
/webapp/assets
/webapp/foobar.txt
/webapp/...
It's seems like the the first mvc:resources tag (assets) works but the second one (version.txt) doesn't.
I get a 404 page.
These are the difference in console log.
2018-07-12 13:58:25,093 DEBUG [http-nio-8080-exec-6] (DispatcherServlet.java:845) - DispatcherServlet with name 'dispatcher' processing GET request for [/mscbackend/foobar.txt]
2018-07-12 13:58:25,093 DEBUG [http-nio-8080-exec-6] (AbstractHandlerMethodMapping.java:297) - Looking up handler method for path /foobar.txt
2018-07-12 13:58:25,096 DEBUG [http-nio-8080-exec-6] (AbstractHandlerMethodMapping.java:305) - Did not find handler method for [/foobar.txt]
2018-07-12 13:58:25,097 DEBUG [http-nio-8080-exec-6] (AbstractUrlHandlerMapping.java:123) - Mapping [/foobar.txt] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/foobar.txt]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#66894a78]]] and 1 interceptor
2018-07-12 14:08:27,165 DEBUG [http-nio-8080-exec-7] (DispatcherServlet.java:845) - DispatcherServlet with name 'dispatcher' processing GET request for [/mscbackend/assets/css/style.css]
2018-07-12 14:08:27,165 DEBUG [http-nio-8080-exec-7] (AbstractHandlerMethodMapping.java:297) - Looking up handler method for path /assets/css/style.css
2018-07-12 14:08:27,169 DEBUG [http-nio-8080-exec-7] (AbstractHandlerMethodMapping.java:305) - Did not find handler method for [/assets/css/style.css]
2018-07-12 14:08:27,169 DEBUG [http-nio-8080-exec-7] (AbstractUrlHandlerMapping.java:168) - Matching patterns for request [/assets/css/style.css] are [/assets/**]
The weird thing is that in another similar project same configuration works without problems.
Thanks in advance for your support.
Try below configuration.
<mvc:resources location="/", mapping="/resources/**"/>
OR if you want to give classpath for a particular location use below.
<mvc:resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**"/>
Try this configuration.
<mvc:resources mapping="/resources/**" location="/resources/" />
I don't why, but sometimes it works. you can give a try.
Related
I ended up getting this log as a result of running my Spring Boot App with a jsp.
2017-12-29 13:30:52.412 WARN 12631 --- [nio-8080-exec-2]
o.s.web.servlet.PageNotFound No mapping found for HTTP
request with URI [/SpringBootTrial/] in DispatcherServlet with name
'dispatcherServlet'
2017-12-29 13:30:56.463 WARN 12631 --- [nio-8080-exec-3]
o.s.web.servlet.PageNotFound No mapping found for HTTP
request with URI [/SpringBootTrial/display] in DispatcherServlet with
name 'dispatcherServlet'
2017-12-29 13:30:56.464 ERROR 12631 --- [nio-8080-exec-3]
o.s.boot.web.support.ErrorPageFilter : Cannot forward to error
page for request [/welcome] as the response has already been
committed. As a result, the response may have the wrong status code.
If your application is running on WebSphere Application Server you may
be able to resolve this problem by setting
com.ibm.ws.webcontainer.invokeFlushAfterService to false
It's evident that in Spring Boot, manual configuration is not needed. So, how should I fix this error?
I am clueless how to fix. I configured the jsp resolver in application.properties.
spring.mvc.view.prefix=/WEB-INF/view/
spring.mvc.view.suffix=.jsp
I have tomcat-embedded-jasper in the pom.xml.
Im wanting to feed multiple configuration files based on properties into –
<beans:property name="locations">
<beans:list>
<beans:value>classpath:properties/local.properties</beans:value>
<beans:value>classpath:properties/${spring.profiles.active}.properties</beans:value>
</beans:list>
</beans:property>
And was under the impression I could use –
<context-param>
<param-name>spring.profiles.active</param-name>
<param-value>profile-a, profile-b</param-value>
</context-param>
I get this error – so its not parsing the param-values -
14:13:12.065 [localhost-startStop-1] TRACE o.s.c.e.PropertySourcesPropertyResolver - getProperty("spring.profiles.active", String)
14:13:12.065 [localhost-startStop-1] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [servletConfigInitParams]
14:13:12.065 [localhost-startStop-1] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Searching for key 'spring.profiles.active' in [servletContextInitParams]
14:13:12.065 [localhost-startStop-1] DEBUG o.s.c.e.PropertySourcesPropertyResolver - Found key 'spring.profiles.active' in [servletContextInitParams] with type [String] and value profile-a, profile-b'
14:13:12.065 [localhost-startStop-1] TRACE o.s.util.PropertyPlaceholderHelper - Resolved placeholder 'spring.profiles.active'
14:13:12.065 [localhost-startStop-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Invoking afterPropertiesSet() on bean with name 'dsProperties'
14:13:12.065 [localhost-startStop-1] INFO o.s.b.f.config.PropertiesFactoryBean - Loading properties file from class path resource [properties/profile-a, profile-b.properties]
14:13:12.065 [localhost-startStop-1] WARN o.s.b.f.config.PropertiesFactoryBean - Could not load properties from class path resource [properties/ profile-a, profile-b.properties.properties]: class path
Can this be done?
I am using spring boot web secure jdbc sample spring-boot-sample-web-secure-jdbc and want to modify it to load static html files (no template like thymeleaf or jsp needed). I have tried putting the html files under src/main/resources but they are not loading.
I noticed that static file example in samples spring-boot-sample-web-static inherits SpringBootServletInitializer for main class while web secure jdbc use WebMvcConfigurerAdapter. I suppose there might be some more configuration needed to make it work them. Below is my dir tree:
src/main/java/hello/MyController.java
src/main/resources/backupshell.html
src/main/resources/myscripts.js
After moving resources to src/main/resources/resources direct url load works fine but via request url mapping as below is not loading:
#RequestMapping("/admin")
//#ResponseBody
String admin() {
//return "Hello World admin!";
return "backupshell";
}
and logs snippet is as below:
2016-04-18 16:16:51.716 DEBUG 8896 --- [nio-8081-exec-9] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapping [/backupshell] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[ServletContext resource [/], class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver#7a9c84a5]]] and 1 interceptor
2016-04-18 16:16:51.716 DEBUG 8896 --- [nio-8081-exec-9] o.s.web.servlet.DispatcherServlet : Last-Modified value for [/backupshell] is: -1
2016-04-18 16:16:51.717 DEBUG 8896 --- [nio-8081-exec-9] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2016-04-18 16:16:51.717 DEBUG 8896 --- [nio-8081-exec-9] o.s.web.servlet.DispatcherServlet : Successfully completed request
2016-04-18 16:16:51.718 DEBUG 8896 --- [nio-8081-exec-9] o.s.web.servlet.DispatcherServlet : Successfully completed request
2016-04-18 16:16:51.718 DEBUG 8896 --- [nio-8081-exec-9] o.s.b.c.web.OrderedRequestContextFilter : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade#24880cb8
2016-04-18 16:16:51.718 DEBUG 8896 --- [nio-8081-exec-9] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
2016-04-18 16:16:51.720 DEBUG 8896 --- [nio-8081-exec-9] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /error
Regards,
Miten.
The root resource directory src/main/resources/ isn't exposed publicly. As described in this post there are 4 directories which are automatically loaded by Spring Boot to serve static content:
/public/
/static/
/resources/
/META-INF/resources/
In your case you can put the HTML and the JS file inside ,e.g., the /public directory:
src/main/resources/public/backupshell.html
src/main/resources/public/myscripts.js
Then you can access the files with the address of your application, with default configuration it would be:
localhost:8080/backupshell.html
Note that 3rd option /resource/ doesn't mean that src/main/resources/ is exposed. It's the src/main/resources/resources/ directory, which can feel quite cumbersome.
I have Spring-boot application which is built with Maven. When I deploy it with STS( Run as Spring Boot App) it works fine, but when I use IntelliJ Idea it doesn't work.
There is no error in log during deployment process. But when I try to refresh page I got this:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing
this as a fallback. Mon Aug 04 14:48:38 CEST 2014 There was an
unexpected error (type=Not Found, status=404).
I've added Spring module to project. After I added this I have added some XML's XML based configurations and my Application.java class to Code based configurations.
I've changed logging to FINEST and noticed that when I reload page there are some differences in logs between working and not working version.
Not working version
DEBUG [org.springframework.web.servlet.view.JstlView] - Forwarding to resource [/WEB-INF/jsp/layouts/default.jsp] in InternalResourceView 'layouts/default'
DEBUG [org.springframework.web.servlet.DispatcherServlet] - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/WEB-INF/jsp/layouts/default.jsp]
DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Looking up handler method for path /WEB-INF/jsp/layouts/default.jsp
DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Did not find handler method for [/WEB-INF/jsp/layouts/default.jsp]
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Matching patterns for request [/WEB-INF/jsp/layouts/default.jsp] are [/**]
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - URI Template variables for request [/WEB-INF/jsp/layouts/default.jsp] are {}
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Mapping [/WEB-INF/jsp/layouts/default.jsp] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.ResourceHttpRequestHandler#29a502a0] and 1 interceptor
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Last-Modified value for [/WEB-INF/jsp/layouts/default.jsp] is: -1
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Ignoring invalid resource path [WEB-INF/jsp/layouts/default.jsp]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - No matching resource found - returning 404
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
DEBUG [org.springframework.web.servlet.DispatcherServlet] - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Looking up handler method for path /error
DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Returning handler method [public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)]
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'basicErrorController'
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Last-Modified value for [/error] is: -1
DEBUG [org.springframework.web.servlet.view.ContentNegotiatingViewResolver] - Requested media types are [text/html, text/html;q=0.8] based on Accept header types and producible media types [text/html])
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Returning cached instance of singleton bean 'error'
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Invoking afterPropertiesSet() on bean with name 'error'
TRACE [class which inherates from UrlBasedViewResolver] - Cached view [error]
TRACE [class which inherates from UrlBasedViewResolver] - Cached view [error]
DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] - Invoking afterPropertiesSet() on bean with name 'error'
DEBUG [org.springframework.web.servlet.view.ContentNegotiatingViewResolver] - Returning [org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView#758e2ae8] based on requested media type 'text/html'
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Rendering view [org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$SpelView#758e2ae8] in DispatcherServlet with name 'dispatcherServlet'
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
Working version
DEBUG [org.springframework.web.servlet.view.JstlView] - Forwarding to resource [/WEB-INF/jsp/layouts/default.jsp] in InternalResourceView 'layouts/default'
INFO [org.apache.jasper.compiler.TldLocationsCache] - At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
DEBUG [org.springframework.web.servlet.DispatcherServlet] - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/bootstrap/css/bootstrap.min.css]
DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Looking up handler method for path /bootstrap/css/bootstrap.min.css
DEBUG [org.springframework.web.servlet.DispatcherServlet] - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/css/bootstrap-fix.css]
DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Looking up handler method for path /css/bootstrap-fix.css
DEBUG [org.springframework.web.servlet.DispatcherServlet] - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/bootstrap/js/bootstrap.min.js]
DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Looking up handler method for path /bootstrap/js/bootstrap.min.js
DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Did not find handler method for [/bootstrap/css/bootstrap.min.css]
DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Did not find handler method for [/css/bootstrap-fix.css]
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Matching patterns for request [/css/bootstrap-fix.css] are [/**]
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - URI Template variables for request [/css/bootstrap-fix.css] are {}
DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Did not find handler method for [/bootstrap/js/bootstrap.min.js]
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Matching patterns for request [/bootstrap/js/bootstrap.min.js] are [/**]
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - URI Template variables for request [/bootstrap/js/bootstrap.min.js] are {}
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Matching patterns for request [/bootstrap/css/bootstrap.min.css] are [/**]
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - URI Template variables for request [/bootstrap/css/bootstrap.min.css] are {}
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Mapping [/css/bootstrap-fix.css] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.ResourceHttpRequestHandler#ff47cbc] and 1 interceptor
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Last-Modified value for [/css/bootstrap-fix.css] is: -1
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [css/bootstrap-fix.css] against base location: ServletContext resource [/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [css/bootstrap-fix.css] against base location: class path resource [META-INF/resources/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [css/bootstrap-fix.css] against base location: class path resource [resources/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [css/bootstrap-fix.css] against base location: class path resource [static/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Found matching resource: class path resource [static/css/bootstrap-fix.css]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Determined media type 'text/css' for class path resource [static/css/bootstrap-fix.css]
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Mapping [/bootstrap/css/bootstrap.min.css] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.ResourceHttpRequestHandler#ff47cbc] and 1 interceptor
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Last-Modified value for [/bootstrap/css/bootstrap.min.css] is: -1
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Mapping [/bootstrap/js/bootstrap.min.js] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.ResourceHttpRequestHandler#ff47cbc] and 1 interceptor
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Last-Modified value for [/bootstrap/js/bootstrap.min.js] is: -1
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [bootstrap/css/bootstrap.min.css] against base location: ServletContext resource [/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [bootstrap/css/bootstrap.min.css] against base location: class path resource [META-INF/resources/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [bootstrap/css/bootstrap.min.css] against base location: class path resource [resources/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [bootstrap/css/bootstrap.min.css] against base location: class path resource [static/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Found matching resource: class path resource [static/bootstrap/css/bootstrap.min.css]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Determined media type 'text/css' for class path resource [static/bootstrap/css/bootstrap.min.css]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [bootstrap/js/bootstrap.min.js] against base location: ServletContext resource [/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [bootstrap/js/bootstrap.min.js] against base location: class path resource [META-INF/resources/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [bootstrap/js/bootstrap.min.js] against base location: class path resource [resources/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [bootstrap/js/bootstrap.min.js] against base location: class path resource [static/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Found matching resource: class path resource [static/bootstrap/js/bootstrap.min.js]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Determined media type 'application/javascript' for class path resource [static/bootstrap/js/bootstrap.min.js]
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
DEBUG [org.springframework.web.servlet.DispatcherServlet] - DispatcherServlet with name 'dispatcherServlet' processing GET request for [/javascript/jquery-1.8.3.min.js]
DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Looking up handler method for path /javascript/jquery-1.8.3.min.js
DEBUG [org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping] - Did not find handler method for [/javascript/jquery-1.8.3.min.js]
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Matching patterns for request [/javascript/jquery-1.8.3.min.js] are [/**]
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - URI Template variables for request [/javascript/jquery-1.8.3.min.js] are {}
DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] - Mapping [/javascript/jquery-1.8.3.min.js] to HandlerExecutionChain with handler [org.springframework.web.servlet.resource.ResourceHttpRequestHandler#ff47cbc] and 1 interceptor
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Last-Modified value for [/javascript/jquery-1.8.3.min.js] is: -1
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [javascript/jquery-1.8.3.min.js] against base location: ServletContext resource [/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [javascript/jquery-1.8.3.min.js] against base location: class path resource [META-INF/resources/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [javascript/jquery-1.8.3.min.js] against base location: class path resource [resources/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Trying relative path [javascript/jquery-1.8.3.min.js] against base location: class path resource [static/]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Found matching resource: class path resource [static/javascript/jquery-1.8.3.min.js]
DEBUG [org.springframework.web.servlet.resource.ResourceHttpRequestHandler] - Determined media type 'application/javascript' for class path resource [static/javascript/jquery-1.8.3.min.js]
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
DEBUG [org.springframework.web.servlet.DispatcherServlet] - Successfully completed request
Class which is giving some error inherates from UrlBasedViewResolver, but I have no idea what can I do with that. Cached view [error] gives me no clue.
What might cause this problems?
EDIT
I forgot to mention:
STS 3.5.1
IntelliJ Idea 13.1
STS has a number of Eclipse plugins that you won't find in IntelliJ. To get a Spring Boot application running from IntelliJ, you need to create a Maven run configuration with the command "spring-boot:run" and make sure it points at the correct module, if your app has multiple modules in it.
I want Tomcat (or rather the admin) to handle the user management.
In Spring I just want to secure some endpoints (index.html and two RESTful controllers) and bind it to either a user or, even better, a group/role.
I want to avoid using xml config inside Spring and use just classes and annotations.
Xml config in tomcat is ok :-)
Booting up spring I see a log entry
2014-06-04 11:37:31.676 INFO 27296 --- [on(2)-127.0.0.1] b.a.s.AuthenticationManagerConfiguration :
Using default password for application endpoints: 543fbdb8-c5d0-4b1b-b7ce-cd6fd008520a
2014-06-04 11:37:31.775 INFO 27296 --- [on(2)-127.0.0.1] o.s.s.web.DefaultSecurityFilterChain : Creating filter chain: org.springframework.security.web.util.matcher.AnyRequestMatcher#1, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter#5867ecdd, ...
...
2014-06-04 11:37:31.794 INFO 27296 --- [on(2)-127.0.0.1] o.s.b.c.embedded.FilterRegistrationBean : Mapping filter: 'springSecurityFilterChain' to: [/*]
...
2014-06-04 11:37:31.907 INFO 27296 --- [on(2)-127.0.0.1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/login] onto handler of type [class org.springframework.web.servlet.mvc.ParameterizableViewController]
Trying to call upon the secured route I get a login form, yet using the information from the tomcat-users.xml I get an error Invalid username and password..
So what am I missing?
Setup
I have
vanilla Apache Tomcat 8.0.8
a modified conf/tomcat-users.xml
a modified conf/server.xml
a cloned deployable version of the Securing Spring Web Guide in my local branch and in this folder (intellij module), see github repo
Configuration
Spring
See the WebSecurityConfig class.
tomcat-users.xml
<!-- ... --->
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<role rolename="ROLE_stakeholder"/>
<user username="stakeholder" password="Foobarbaz" roles="ROLE_stakeholder,manager-gui,manager-script,manager-jmx,manager-status"/>
<!-- ... --->
server.xml
<!-- ... --->
<Engine name="Catalina" defaultHost="localhost">
<!-- ... --->
<Realm className="org.apache.catalina.realm.MemoryRealm" />
</Engine>