Path with “WEB-INF” or “META-INF”

John Doe ·

1957 Views

The spring boot error Path with “WEB-INF” or “META-INF” occurs when the jsp page url is invoked and the tomcat jasper dependency is not configured in the application. The jsp files are compiled and rendered using the tomcat embedded jasper maven dependency. If the maven dependency is not configured in the spring boot application, the “path with WEB-INF or META-INF” error will be shown in the console.

In the spring boot application, when you access a jsp page in browser, it shows “Whitelabel Error Page, There was an unexpected error (type=Not Found, status=404).” error in the browser. The exception to this is “HTTP 404 – page not found”. In the spring boot console log, the error is shown as ‘Path with ‘WEB-INF’ or ‘META-INF’.

The ResourceHttpRequestHandler class will throw the error as “o.s.w.s.r.ResourceHttpRequestHandler : Path with “WEB-INF” or “META-INF”:”

 

Exception

The exception stack trace will be shown below. This will be displayed in the console when a jsp page is invoked.

2019-10-03 13:17:57.140  WARN 3200 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler     : Path with "WEB-INF" or "META-INF": [WEB-INF/jsp/helloworld.jsp]
 2019-10-03 13:17:57.154  WARN 3200 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler     : Path with "WEB-INF" or "META-INF": [WEB-INF/jsp/error.jsp]

 

How to reproduce this issue

This error can be replicated in the mvc spring boot application. Follow the steps below to reproduce this issue. Create a spring boot mvc project in the Spring Tool Suite editor. Set up the jsp folder in the application.properties file as shown below.

application.properties

spring.mvc.view.prefix:/WEB-INF/jsp/
spring.mvc.view.suffix:.jsp

Create a rest controller class to configure and invoke a url that will map to jsp file. Create a method in the controller class and configure the request mapping url to invoke. Configure a jsp file in the method that will be rendered when the url is invoked.

HelloWorldController.java

package com.yawintutor;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HelloWorldController {

	@RequestMapping("/HelloWorld")
	public ModelAndView firstPage() {
		return new ModelAndView("helloworld");
	}

}

Create a jsp file that is configured in the controller class. In this example, a helloworld.jsp file is created in the src / main / webapp / WEB-INF / jsp / folder. The jsp file contains a simple message.

src/main/webapp/WEB-INF/jsp/helloworld .jsp

<h1>Welcome to Hello World!</h1>

Open a browser and call the url as “http://localhost:8080/HelloWorld”. This url should invoke firstPage method in HelloWorldController class. The model view is configured with helloworld. the file in src/main/webapp/WEB-INF/jsp/helloworld.jsp should be rendered.

 

Root Cause

The jsp path resolving class is available in tomcat jasper package. The dependency of tomcat jasper is not added in pom.xml. So the jsp path is not resolved by spring boot application

 

Solution

The dependent jars are available in tomcat jasper. Add tomcat jasper dependency in pom.xml file

<dependency>
	<groupId>org.apache.tomcat.embed</groupId>
	<artifactId>tomcat-embed-jasper</artifactId>
</dependency>

 

Ref.

Skip to content Home Java C Spring Boot Issues Spring Boot Python Database Others Technicals Contact Us Home Java C Spring Boot Issues Spring Boot Python Database Others Technicals Contact Us Path with “WEB-INF” or “META-INF” The spring boot error Path wi

 

java spring