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

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>



17 Comments

  • Vaishnavi , September 21, 2023 @ 12:20 PM

    Same happening with me, do you get to resolve the issue?

  • Arshad , April 3, 2023 @ 12:08 AM

    still in new spring boot web application you need to include this, else jsp will not work. why Spring boot team not solving this issue

  • vivek , October 30, 2022 @ 10:40 PM

    remove version number from tomcat jasper

    dependencies {

    implementation ‘org.apache.tomcat.embed:tomcat-embed-jasper:10.1.0’—(remove this number and semicolon)

    testImplementation ‘org.springframework.boot:spring-boot-starter-test:2.7.5’

    }

  • Anuj Solanki , September 2, 2022 @ 10:30 PM

    Hi Yawin,
    Even after using the same dependency that you have mentioned i am still getting the same problem. The IDE i am using is intellij
    is there anything else needs to be done ?

    • Abdul Dalvi , June 13, 2023 @ 2:24 PM

      did you get a solution for this

  • Sher , July 10, 2022 @ 2:23 PM

    Thanks, works for me

  • Ganesh , March 29, 2021 @ 10:03 PM

    Thank you. Was struggling for a while. It works now.

  • George B , February 27, 2021 @ 11:14 PM

    Hi Yawin,

    When I have my JSTL and Jasper Embed dependencies declared with a version number in the pom.xml, I get this error. But removing the version from the dependency fixes this. Any idea why?

    Code that works:

    org.apache.tomcat.embed
    tomcat-embed-jasper

    javax.servlet
    jstl

    Code that produce the error you mentioned:

    org.apache.tomcat.embed
    tomcat-embed-jasper
    10.0.2

    javax.servlet
    jstl
    1.2

    Any insight is appreciated, thank you!

  • sunitha.s , December 10, 2020 @ 10:03 PM

    thank you so much. it works for me.

  • Ritesh , November 21, 2020 @ 10:54 AM

    Thanks its worked nicely for me…

  • Shivam Rai , November 6, 2020 @ 6:36 PM

    Thanks, worked for me

  • AK , July 23, 2020 @ 7:41 PM

    I have same problem with html pages. Can anyone help in this.

  • Manpreet Singh , July 7, 2020 @ 9:59 AM

    Worked for me.

    Thanks

  • JT , June 30, 2020 @ 6:18 PM

    Perfect, my code is now working, thank you!

  • Albert , April 4, 2020 @ 3:28 PM

    Thanks, works for me

  • Ram , December 24, 2019 @ 11:49 PM

    added everything as on the page, but the error is still 404

    • Yawin Tutor , December 28, 2019 @ 1:15 PM

      Hi Ram, Please share your code link

Leave a Reply

Your email address will not be published. Required fields are marked *