Making a simple test with Apache Tomcat 10.1.2 embedded server in Spring Boot 3.0.0-RC2, this exception is raised when it runs:
mvnw spring-boot:run
...
2022-11-17T17:12:30.261+01:00 INFO 2508 --- [ main] c.e.restservice.RestServiceApplication : Starting RestServiceApplication using Java 17.0.5 with PID 2508 (C:\Progetti\Ericsson\gs-rest-service-main\initial\target\classes started by eanluci in C:\Progetti\Ericsson\gs-rest-service-main\initial)
2022-11-17T17:12:30.267+01:00 INFO 2508 --- [ main] c.e.restservice.RestServiceApplication : No active profile set, falling back to 1 default profile: "default"
2022-11-17T17:12:31.191+01:00 WARN 2508 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server
2022-11-17T17:12:31.199+01:00 INFO 2508 --- [ main] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2022-11-17T17:12:31.213+01:00 ERROR 2508 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.context.ApplicationContextException: Unable to start web server
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:164) ~[spring-boot-3.0.0-RC2.jar:3.0.0-RC2]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:578) ~[spring-context-6.0.0-RC4.jar:6.0.0-RC4]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146) ~[spring-boot-3.0.0-RC2.jar:3.0.0-RC2]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:730) ~[spring-boot-3.0.0-RC2.jar:3.0.0-RC2]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:432) ~[spring-boot-3.0.0-RC2.jar:3.0.0-RC2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-3.0.0-RC2.jar:3.0.0-RC2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1302) ~[spring-boot-3.0.0-RC2.jar:3.0.0-RC2]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1291) ~[spring-boot-3.0.0-RC2.jar:3.0.0-RC2]
at com.example.restservice.RestServiceApplication.main(RestServiceApplication.java:10) ~[classes/:na]
Caused by: java.lang.NoClassDefFoundError: org/apache/tomcat/jakartaee/EESpecProfile
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.prepareContext(TomcatServletWebServerFactory.java:244) ~[spring-boot-3.0.0-RC2.jar:3.0.0-RC2]
at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:209) ~[spring-boot-3.0.0-RC2.jar:3.0.0-RC2]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183) ~[spring-boot-3.0.0-RC2.jar:3.0.0-RC2]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161) ~[spring-boot-3.0.0-RC2.jar:3.0.0-RC2]
... 8 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.jakartaee.EESpecProfile
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
... 12 common frames omitted
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 03:13 min
[INFO] Finished at: 2022-11-17T17:12:31+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:3.0.0-RC2:run (default-cli) on project rest-service-initial: Process terminated with exit code: 1 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
If I change the version to either tomcat 10.1.1 or tomcat 10.1.0 in my pom.xml file there is no error and the embedded server starts: pom.xml.txt
Comment From: wilkinsona
This is due to a bug in Tomcat and is why our dependency management still uses 10.1.1. It's been fixed in 10.1.3 snapshots.
Comment From: andrealuciano71
Thanks a lot Whilkison, I reported it into my Tomcat issue: https://bz.apache.org/bugzilla/show_bug.cgi?id=66353
Comment From: wilkinsona
In the future, please don't cross-post like this. You've reported the same problem in three separate places to three separate teams, wasting the time of at least two of them.
Comment From: andrealuciano71
Good advice, my fault. Sorry for time wasted, it's my first time with Spring. Beforehand I googled for my error and I didn't find anything. At least I hope this issue is useful for many others that will encounter the same error.