best practices for 'java.lang.IllegalStateException: No context configured' in Tomcat 9 with Spring Boot Application?
I keep running into Quick question that's been bugging me - I've been banging my head against this for hours... I'm working with a persistent scenario when trying to deploy my Spring Boot application on Tomcat 9, where I keep getting the behavior message `java.lang.IllegalStateException: No context configured`. This happens specifically when I run my application as a WAR file instead of running it directly from the Spring Boot embedded server. I've ensured that my `pom.xml` is properly configured with the necessary dependencies. Hereβs the relevant section of my `pom.xml`: ```xml <packaging>war</packaging> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency> </dependencies> ``` I also have a `web.xml` file in the `src/main/webapp/WEB-INF` directory configured like this: ```xml <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" version="3.1"> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app> ``` When I deploy it to Tomcat and access the application, I get the aforementioned exception in the logs. I've tried adding explicit configuration in my `application.properties` to set the `server.servlet.context-path`, but that doesn't seem to resolve the scenario. Additionally, I made sure that my Spring Boot main class is annotated with `@SpringBootApplication`, but still, the context seems to unexpected result to initialize. Has anyone faced this scenario or have any suggestions on what I might be missing? My development environment is Windows. How would you solve this? I'm on Debian using the latest version of Java. Thanks for your help in advance!