This error suggests that the application you are trying to run cannot instantiate an instance of apache tomcat. Make sure you are running the applications with tomcat.
Solutions:
This error can be solved in two ways;
Check all dependencies:
If after checking all your dependencies you experience the same problem, then try to add the following code in your configuration class;
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory factory =
new TomcatEmbeddedServletContainerFactory();
return factory;
}
External Instance:
If you are using an external instance of tomcat (especially for IntelliJ ), the problem could be that the IDE is trying to start the embedded tomcat. In this case, remove the following from your pom.xml and then configure the external tomcat using the “Edit Configuration” wizard.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
Note:
If you are encountering this error while using IntelliJ and you are trying to start the application with the run button, Try starting the application from the command line instead, like ensure that you are incorrect directory assuming this is as spring boot application run mvn spring-boot: run.
Additionally, you can also see an error when your spring application depends on another application. In this case, you have to start the other application first an