Hi there, faced with the following issue. Migration from spring boot 2.7 to spring 3.1. Used jetty before, but found out that there is no jetty yet for servlet 6.0, so switched to tomcat. Updated dependency, fixed problems and tested that locally service is starting up. Build docker image, tested that it's starting up locally too. Uploaded image to kubernetes and faced with the following error during spring boot initialization:

[2023-07-26T16:29:27.879] [INFO] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.s.c.c.s.GenericScope] BeanFactory id=3378f425-7b4c-3ae6-a10f-599c5e2c618c
[2023-07-26T16:29:31.262] [WARN] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.s.c.s.AbstractApplicationContext] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server
[2023-07-26T16:29:31.280] [INFO] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.s.b.a.l.ConditionEvaluationReportLogger] 
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2023-07-26 16:29:31.385  INFO  [thread=Profiler results dumper /app/ncdiag/localdump][class=com.netcracker.profiler.dump.DumperThread] - Unable to connect to remote collector java.net.UnknownHostException: nc-diagnostic-agent
[2023-07-26T16:29:31.384] [ERROR] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.s.b.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)
 at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:602)
 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
 at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734)
 at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:436)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:312)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306)
 at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295)
 at ***.ServiceManagerApplication.main(ServiceManagerApplication.java:22)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.base/java.lang.reflect.Method.invoke(Method.java:568)
 at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49)
 at org.springframework.boot.loader.Launcher.launch(Launcher.java:95)
 at org.springframework.boot.loader.Launcher.launch(Launcher.java:58)
 at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:65)
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletRequest
 at org.apache.catalina.core.StandardEngine.<init>(StandardEngine.java:63)
 at org.apache.catalina.startup.Tomcat.getEngine(Tomcat.java:626)
 at org.apache.catalina.startup.Tomcat.getHost(Tomcat.java:606)
 at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:205)
 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:183)
 at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:161)
 ... 16 common frames omitted
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletRequest
 at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
 at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:149)
 at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
 ... 22 common frames omitted

I am sure that javax servlet can not be used as it's tomcat 11 and spring boot 3.1, and I can not understand how is it possible that such error can occur only on kubernetes env. I assumed that such problem can be faced if some dependency inside my app is not migrated to new version of spring/servlet api, but I do not except this at a servlet container initialization.

Then I tried to add

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <scope>provided</scope>
</dependency>

and rebuild the service, and as I expected, service is started without such error. I want to investigate a bit deeper what is happing there - StandardEngine.java:63, but maybe someone has an idea, how can it be possible? Logs from local docker as a proof that servlet container is started:

[2023-07-26T16:36:44.097] [INFO] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.s.b.StartupInfoLogger] Starting ServiceManagerApplication v6.0.0 using Java 17.0.7 with PID 75 (/app/app.jar started by appuser in /app)
[2023-07-26T16:36:44.104] [INFO] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.s.b.SpringApplication] The following 1 profile is active: "prod"
[2023-07-26T16:36:46.389] [INFO] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.s.d.r.c.RepositoryConfigurationDelegate] Bootstrapping Spring Data ArangoDB repositories in DEFAULT mode.
[2023-07-26T16:36:46.574] [INFO] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.s.d.r.c.RepositoryConfigurationDelegate] Finished Spring Data repository scanning in 172 ms. Found 13 ArangoDB repository interfaces.
[2023-07-26T16:36:48.928] [INFO] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.s.c.c.s.GenericScope] BeanFactory id=195b2643-45c4-3e15-b68d-e782aab82435
[2023-07-26T16:36:50.687] [INFO] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.s.b.w.e.t.TomcatWebServer] Tomcat initialized with port(s): 8080 (http)
[2023-07-26T16:36:50.718] [INFO] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.a.j.l.DirectJDKLog] Starting service [Tomcat]
[2023-07-26T16:36:50.719] [INFO] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.a.j.l.DirectJDKLog] Starting Servlet engine: [Apache Tomcat/10.1.11]
[2023-07-26T16:36:50.845] [INFO] [x_request_id=-] [tenant_id=-] [thread=main] [class=o.a.j.l.DirectJDKLog] Initializing Spring embedded WebApplicationContext

Comment From: wilkinsona

You must have an old version of StandardEngine on the classpath somehow that references javax.servlet.ServletRequest either directly or through another class. To diagnose where that class is coming from, I would run your application with -verbose:class.

I'm going to close this as the contents of your application's classpath and your Kubernetes environment are out of Spring Boot's control. If the above doesn't help and you'd like further assistance, please follow up on Stack Overflow.