I built my package as war file with Jenkins. and I deployed it on the Tomcat 9.0.71. and when I tried to access it, it sent 404 error with thie message: The requested resource [/demo/api/get-string] is not available

here is the logs from catalina.out:

28-Feb-2023 09:34:09.646 INFO [http-nio-8082-exec-10] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/storage/public_html/demo.war]
28-Feb-2023 09:34:09.731 WARNING [http-nio-8082-exec-10] org.apache.tomcat.util.descriptor.web.WebXml.setVersion Unknown version string [5.0]. Default version will be used.
28-Feb-2023 09:34:10.500 INFO [http-nio-8082-exec-10] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
28-Feb-2023 09:34:10.505 INFO [http-nio-8082-exec-10] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/storage/public_html/demo.war] has finished in [858] ms

I guessed the war file has no problem, because I can access to endpoints well when I started war file as stand-alone with this command: nohup java -jar demo.war

Otherwise, when I tested to deploy the war file which is built with spring boot 2.7.9 and Java 11, it is working well.


  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.7.9)

2023-02-28 09:52:43.724  INFO 11949 --- [nio-8082-exec-6] com.example.demo.ServletInitializer      : Starting ServletInitializer v0.0.1-SNAPSHOT using Java 17.0.6 on ds119tk-tw01 with PID 11949 (/storage/public_html/demo/WEB-INF/classes started by root in /storage/server/tomcat/bin)
2023-02-28 09:52:43.727  INFO 11949 --- [nio-8082-exec-6] com.example.demo.ServletInitializer      : No active profile set, falling back to 1 default profile: "default"
2023-02-28 09:52:44.744  INFO 11949 --- [nio-8082-exec-6] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 951 ms
2023-02-28 09:52:45.448  INFO 11949 --- [nio-8082-exec-6] com.example.demo.ServletInitializer      : Started ServletInitializer in 2.241 seconds (JVM running for 1259.427)
28-Feb-2023 09:52:45.462 INFO [http-nio-8082-exec-6] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/storage/public_html/demo.war] has finished in [3,444] ms
2023-02-28 09:53:18.553  INFO 11949 --- [nio-8082-exec-2] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-02-28 09:53:18.554  INFO 11949 --- [nio-8082-exec-2] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms

so I guessed it is spring boot 3 problem with tomcat 9 in Java 17 environment.

Comment From: philwebb

Spring Boot 3.0 uses Jakarta EE libraries and is baselined on Servlet 6.0. You'll need to Use Tomcat 10 for Spring Boot 3.0 applications. See https://tomcat.apache.org/whichversion.html and https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#jakarta-ee