6

I have a spring boot project and I am trying to use Tomcat 10 embedded instead of Tomcat 7. I add the following to my POM...

<properties>
    <tomcat.version>10.0.5</tomcat.version>
    ...
</properties>

Then I run the same command I was running before...

mvn clean package -U && java -cp target\my.jar;props -Dloader.main=com.my.Main org.springframework.boot.loader.PropertiesLauncher

But now it just starts and then shuts itself down. The final messages are...

2021-05-13 15:35:42.105  INFO 10084 --- [           main] com.my.Main                   : Started Main in 42.918 seconds (JVM running for 44.009)
2021-05-13 15:35:42.190  INFO 10084 --- [extShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

Why would this happen and how can I upgrade without this side effect?

JGleason
  • 3,067
  • 6
  • 20
  • 54
  • Does this answer your question? [Servlet 5.0 JAR throws compile error on javax.servlet.\* but Servlet 4.0 JAR does not](https://stackoverflow.com/questions/64387472/servlet-5-0-jar-throws-compile-error-on-javax-servlet-but-servlet-4-0-jar-does) – Olaf Kock May 15 '21 at 09:01

1 Answers1

18

Tomcat 10 is a Jakarta EE 9 servlet container. It basically means, that all javax.* packages were renamed to jakarta.* for copyright reasons (Oracle didn't allow the Eclipse Foundation to use the javax.* names).

Spring Boot 2 and Spring 5 support only the previous Java EE 8 specification, you need to wait for Spring Boot 3 and Spring 6 for Tomcat 10 support. Alternatively you can pass Spring libraries through the Apache Tomcat Migration Tool, which just reached version 1.0 or downgrade to Tomcat 9.0.

See also

Piotr P. Karwasz
  • 12,857
  • 3
  • 20
  • 43