2

I have been using Spring Boot ReST APIs for quite some time; I thought of experimenting with web-MVC. However, I have got stuck on the first part itself.

I have uploaded the project on GitHub

What I have done so far:

  1. Defined POM.xml with spring-boot-starter-web + tomcat-embed-jasper mainly.
  2. Defined a @Controller with @GetMapping("/greeting"), which returns the name of a view - hello
  3. Defined following properties:

    spring.mvc.view.prefix=/WEB-INF/views/

    spring.mvc.view.suffix=.jsp

  4. Created a very basic view hello.jsp at src/main/web/WEB-INF/views/hello.jsp

  5. Created a main Application to run as SpringBootApplication.

Error:

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Mon Mar 26 22:55:03 IST 2018

There was an unexpected error (type=Not Found, status=404). No message available

Logs:

2018-03-26 22:55:02.998 DEBUG 7132 --- [nio-8080-exec-1] o.a.coyote.http11.Http11InputBuffer      : Received [GET /greeting HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
DNT: 1
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,hi;q=0.8

]
2018-03-26 22:55:03.043 DEBUG 7132 --- [nio-8080-exec-1] org.apache.tomcat.util.http.Parameters   : Set query string encoding to UTF-8
2018-03-26 22:55:03.054 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.authenticator.AuthenticatorBase    : Security checking request GET /greeting
2018-03-26 22:55:03.054 DEBUG 7132 --- [nio-8080-exec-1] org.apache.catalina.realm.RealmBase      :   No applicable constraints defined
2018-03-26 22:55:03.063 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.a.jaspic.AuthConfigFactoryImpl     : Loading persistent provider registrations from [C:\Users\NirMit\AppData\Local\Temp\tomcat.3836668232954126555.8080\conf\jaspic-providers.xml]
2018-03-26 22:55:03.064 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.authenticator.AuthenticatorBase    :  Not subject to any constraint
2018-03-26 22:55:03.067 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing servlet 'dispatcherServlet'
2018-03-26 22:55:03.068  INFO 7132 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2018-03-26 22:55:03.069  INFO 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2018-03-26 22:55:03.069 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'multipartResolver'
2018-03-26 22:55:03.069 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Using MultipartResolver [org.springframework.web.multipart.support.StandardServletMultipartResolver@a8d0be]
2018-03-26 22:55:03.070 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Creating instance of bean 'org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver'
2018-03-26 22:55:03.074 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(java.lang.ObjectCustomizer)
2018-03-26 22:55:03.074 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.077 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolverCustomizer)
2018-03-26 22:55:03.079 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.082 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(org.springframework.web.servlet.LocaleResolverCustomizer)
2018-03-26 22:55:03.084 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.084 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Finished creating instance of bean 'org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver'
2018-03-26 22:55:03.085 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Unable to locate LocaleResolver with name 'localeResolver': using default [org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver@1c2a3a2]
2018-03-26 22:55:03.086 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Creating instance of bean 'org.springframework.web.servlet.theme.FixedThemeResolver'
2018-03-26 22:55:03.091 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(java.lang.ObjectCustomizer)
2018-03-26 22:55:03.091 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.093 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(org.springframework.web.servlet.theme.AbstractThemeResolverCustomizer)
2018-03-26 22:55:03.095 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.097 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(org.springframework.web.servlet.theme.FixedThemeResolverCustomizer)
2018-03-26 22:55:03.098 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.101 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(org.springframework.web.servlet.ThemeResolverCustomizer)
2018-03-26 22:55:03.108 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.109 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Finished creating instance of bean 'org.springframework.web.servlet.theme.FixedThemeResolver'
2018-03-26 22:55:03.115 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Unable to locate ThemeResolver with name 'themeResolver': using default [org.springframework.web.servlet.theme.FixedThemeResolver@1855c21]
2018-03-26 22:55:03.116 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'requestMappingHandlerMapping'
2018-03-26 22:55:03.116 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'viewControllerHandlerMapping'
2018-03-26 22:55:03.116 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'beanNameHandlerMapping'
2018-03-26 22:55:03.116 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'resourceHandlerMapping'
2018-03-26 22:55:03.116 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'defaultServletHandlerMapping'
2018-03-26 22:55:03.116 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'faviconHandlerMapping'
2018-03-26 22:55:03.116 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'welcomePageHandlerMapping'
2018-03-26 22:55:03.117 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'requestMappingHandlerAdapter'
2018-03-26 22:55:03.117 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'httpRequestHandlerAdapter'
2018-03-26 22:55:03.117 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'simpleControllerHandlerAdapter'
2018-03-26 22:55:03.117 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'errorAttributes'
2018-03-26 22:55:03.117 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'handlerExceptionResolver'
2018-03-26 22:55:03.121 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Creating instance of bean 'org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator'
2018-03-26 22:55:03.124 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(java.lang.ObjectCustomizer)
2018-03-26 22:55:03.124 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.126 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(org.springframework.web.servlet.view.DefaultRequestToViewNameTranslatorCustomizer)
2018-03-26 22:55:03.128 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.130 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(org.springframework.web.servlet.RequestToViewNameTranslatorCustomizer)
2018-03-26 22:55:03.132 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.133 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Finished creating instance of bean 'org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator'
2018-03-26 22:55:03.133 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Unable to locate RequestToViewNameTranslator with name 'viewNameTranslator': using default [org.springframework.web.servlet.view.DefaultRequestToViewNameTranslator@99d4c6]
2018-03-26 22:55:03.133 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'beanNameViewResolver'
2018-03-26 22:55:03.134 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'mvcViewResolver'
2018-03-26 22:55:03.134 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'defaultViewResolver'
2018-03-26 22:55:03.134 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'viewResolver'
2018-03-26 22:55:03.137 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Creating instance of bean 'org.springframework.web.servlet.support.SessionFlashMapManager'
2018-03-26 22:55:03.141 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(java.lang.ObjectCustomizer)
2018-03-26 22:55:03.142 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.143 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(org.springframework.web.servlet.support.AbstractFlashMapManagerCustomizer)
2018-03-26 22:55:03.146 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.153 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(org.springframework.web.servlet.support.SessionFlashMapManagerCustomizer)
2018-03-26 22:55:03.156 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.158 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     findClass(org.springframework.web.servlet.FlashMapManagerCustomizer)
2018-03-26 22:55:03.160 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.loader.WebappClassLoaderBase       :     --> Returning ClassNotFoundException
2018-03-26 22:55:03.161 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Finished creating instance of bean 'org.springframework.web.servlet.support.SessionFlashMapManager'
2018-03-26 22:55:03.161 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Unable to locate FlashMapManager with name 'flashMapManager': using default [org.springframework.web.servlet.support.SessionFlashMapManager@3d023d]
2018-03-26 22:55:03.161 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Published WebApplicationContext of servlet 'dispatcherServlet' as ServletContext attribute with name [org.springframework.web.servlet.FrameworkServlet.CONTEXT.dispatcherServlet]
2018-03-26 22:55:03.161  INFO 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 92 ms
2018-03-26 22:55:03.161 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Servlet 'dispatcherServlet' configured successfully
2018-03-26 22:55:03.177 DEBUG 7132 --- [169.254.165.176] sun.rmi.transport.tcp                    : RMI TCP Connection(3)-169.254.165.176: (port 51150) connection closed
2018-03-26 22:55:03.177 DEBUG 7132 --- [169.254.165.176] sun.rmi.transport.tcp                    : RMI TCP Connection(3)-169.254.165.176: close connection
2018-03-26 22:55:03.200 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.w.s.f.OrderedRequestContextFilter  : Bound request context to thread: org.apache.catalina.connector.RequestFacade@1cc2c8
2018-03-26 22:55:03.211 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/greeting]
2018-03-26 22:55:03.217 DEBUG 7132 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /greeting
2018-03-26 22:55:03.223 DEBUG 7132 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public java.lang.String com.khandhedia.sprinboot.mvc.demo1.controller.GreetingController.greetingForm(org.springframework.ui.Model)]
2018-03-26 22:55:03.223 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'greetingController'
2018-03-26 22:55:03.224 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Last-Modified value for [/greeting] is: -1
2018-03-26 22:55:03.285 DEBUG 7132 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Requested media types are [text/html, application/xhtml+xml, image/webp, image/apng, application/xml;q=0.9, */*;q=0.8] based on Accept header types and producible media types [*/*])
2018-03-26 22:55:03.285 DEBUG 7132 --- [nio-8080-exec-1] o.s.w.servlet.view.BeanNameViewResolver  : No matching bean found for view name 'hello'
2018-03-26 22:55:03.293 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Invoking afterPropertiesSet() on bean with name 'hello'
2018-03-26 22:55:03.295 DEBUG 7132 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Returning [org.springframework.web.servlet.view.JstlView: name 'hello'; URL [/WEB-INF/views/hello.jsp]] based on requested media type 'text/html'
2018-03-26 22:55:03.295 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Rendering view [org.springframework.web.servlet.view.JstlView: name 'hello'; URL [/WEB-INF/views/hello.jsp]] in DispatcherServlet with name 'dispatcherServlet'
2018-03-26 22:55:03.296 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.view.JstlView            : Added model object 'name' of type [java.lang.String] to request in view with name 'hello'
2018-03-26 22:55:03.307 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.view.JstlView            : Forwarding to resource [/WEB-INF/views/hello.jsp] in InternalResourceView 'hello'
2018-03-26 22:55:03.318 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/WEB-INF/views/hello.jsp]
2018-03-26 22:55:03.318 DEBUG 7132 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /WEB-INF/views/hello.jsp
2018-03-26 22:55:03.340 DEBUG 7132 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Did not find handler method for [/WEB-INF/views/hello.jsp]
2018-03-26 22:55:03.340 DEBUG 7132 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Matching patterns for request [/WEB-INF/views/hello.jsp] are [/**]
2018-03-26 22:55:03.342 DEBUG 7132 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : URI Template variables for request [/WEB-INF/views/hello.jsp] are {}
2018-03-26 22:55:03.343 DEBUG 7132 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapping [/WEB-INF/views/hello.jsp] to HandlerExecutionChain with handler [ResourceHttpRequestHandler [locations=[class path resource [META-INF/resources/], class path resource [resources/], class path resource [static/], class path resource [public/], ServletContext resource [/]], resolvers=[org.springframework.web.servlet.resource.PathResourceResolver@1113a37]]] and 1 interceptor
2018-03-26 22:55:03.344 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Last-Modified value for [/WEB-INF/views/hello.jsp] is: -1
2018-03-26 22:55:03.344 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
2018-03-26 22:55:03.344 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Successfully completed request
2018-03-26 22:55:03.347 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    :  Disabling the response for further output
2018-03-26 22:55:03.347 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Successfully completed request
2018-03-26 22:55:03.347 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.w.s.f.OrderedRequestContextFilter  : Cleared thread-bound request context: org.apache.catalina.connector.RequestFacade@1cc2c8
2018-03-26 22:55:03.348 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost]           : Processing ErrorPage[errorCode=0, location=/error]
2018-03-26 22:55:03.349 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : DispatcherServlet with name 'dispatcherServlet' processing GET request for [/error]
2018-03-26 22:55:03.350 DEBUG 7132 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Looking up handler method for path /error
2018-03-26 22:55:03.351 DEBUG 7132 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Returning handler method [public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)]
2018-03-26 22:55:03.351 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'basicErrorController'
2018-03-26 22:55:03.352 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Last-Modified value for [/error] is: -1
2018-03-26 22:55:03.354 DEBUG 7132 --- [nio-8080-exec-1] o.s.c.e.PropertySourcesPropertyResolver  : Could not find key 'spring.template.provider.cache' in any property source
2018-03-26 22:55:03.358 DEBUG 7132 --- [nio-8080-exec-1] o.s.c.e.PropertySourcesPropertyResolver  : Could not find key 'spring.template.provider.cache' in any property source
2018-03-26 22:55:03.383 DEBUG 7132 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Requested media types are [text/html, text/html;q=0.8] based on Accept header types and producible media types [text/html])
2018-03-26 22:55:03.383 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'error'
2018-03-26 22:55:03.383 DEBUG 7132 --- [nio-8080-exec-1] o.s.b.f.s.DefaultListableBeanFactory     : Invoking afterPropertiesSet() on bean with name 'error'
2018-03-26 22:55:03.383 DEBUG 7132 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Returning [org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$SpelView@1943f03] based on requested media type 'text/html'
2018-03-26 22:55:03.383 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Rendering view [org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration$SpelView@1943f03] in DispatcherServlet with name 'dispatcherServlet'
2018-03-26 22:55:03.420 DEBUG 7132 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Successfully completed request
2018-03-26 22:55:03.420 DEBUG 7132 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    :  Disabling the response for further output
2018-03-26 22:55:03.439 DEBUG 7132 --- [nio-8080-exec-1] o.a.tomcat.util.net.SocketWrapperBase    : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@10910ae:org.apache.tomcat.util.net.NioChannel@4cbd6d:java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:8080 remote=/0:0:0:0:0:0:0:1:51167]], Read from buffer: [0]
2018-03-26 22:55:03.440 DEBUG 7132 --- [nio-8080-exec-1] o.apache.coyote.http11.Http11Processor   : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@10910ae:org.apache.tomcat.util.net.NioChannel@4cbd6d:java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:8080 remote=/0:0:0:0:0:0:0:1:51167]], Status in: [OPEN_READ], State out: [OPEN]
2018-03-26 22:55:09.322 DEBUG 7132 --- [nio-8080-exec-5] o.a.tomcat.util.net.SocketWrapperBase    : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@10910ae:org.apache.tomcat.util.net.NioChannel@4cbd6d:java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:8080 remote=/0:0:0:0:0:0:0:1:51167]], Read from buffer: [0]
2018-03-26 22:55:09.322 DEBUG 7132 --- [nio-8080-exec-5] o.apache.coyote.http11.Http11Processor   : Error parsing HTTP request header

EDIT:

I tried following changes as per the comments; however, it doesn't seem to help yet.

  1. Putting hello.jsp in src/main/resources/templates/WEB-INF/views
  2. Putting hello.jsp in src/main/resources/static/WEB-INF/views
  3. Putting hello.jsp in src/main/resources/WEB-INF/views
  4. Putting hello.jsp in src/main/webapp/WEB-INF/views

Please advise.

2
  • src/main/web, the 'web' folder should have been 'webapp' Commented Mar 26, 2018 at 18:13
  • @HimanshuBhardwaj I tried renaming to 'webapp' and also performed a few more P&Cs, but doesn't help. Commented Mar 27, 2018 at 6:29

2 Answers 2

6

The issue was with the provided scope of Maven Dependency tomcat-embed-jasper which is used to compile the JSPs.

With default scope for this maven dependency, it flies!

    <!-- Tomcat for JSP rendering -->
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
    </dependency>

Two cents from my analysis!

What is the use of this dependency when we already have spring-boot-starter-web?

The spring-boot-starter-web includes the spring-boot-starter-tomcat and the spring-boot-starter-tomcat includes the tomcat-embed-core.

But, tomcat-embed-core doesn't include tomcat-embed-jasper.

Now, according to maven docs, if the tomcat-embed-jasper is marked as provided, it means that it expects the JDK or a container to provide the dependency at runtime. This scope is only available on the compilation and test classpath, and is not transitive. Hence, effectively this dependency is not available when JSPs are being compiled.

By marking this dependency scope as compile, it is made available in all the classpaths and to all the dependent projects as well.

Summary: The spring-boot-starter-web has tomcat embedded dependency but it doesn't include the jasper embedded dependency. One needs to add this dependency with default compile scope.

Where to place the JSPs/View Components in a Spring Boot Project?

  1. Create a Web Project using Spring Inializr or IntelliJ Spring Plugins.
  2. Add Web framework support using IDE. It may create a directory as src/main/web/WEB-INF
  3. Rename the directory from web to webapp
  4. Create the view components like JSPs at src/main/webapp/WEB-INF/views/
  5. Define following properties in application.properties

    spring.mvc.view.prefix=/WEB-INF/views/
    spring.mvc.view.suffix=.jsp
    
Sign up to request clarification or add additional context in comments.

Comments

4
src/main/web/WEB-INF/views/hello.jsp

will not be found by Spring Boot. As a Spring Boot convention you should put your views under resources folder:

src/main/resources/templates/...

And for your CSS:

src/main/resources/static/...

And if you are using Spring Boot, then it's a good idea to use the project initializer: https://start.spring.io/ from there choose what view technology you want, and Spring Boot will add its dependencies for you, so you don't need to add them or configure them yourself(step 3).

1 Comment

I tried the suggested changes and few more P&Cs, but it didn't fly though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.