Open tippexs opened 1 year ago
Hi there,
I've done some tests and investigations on that topic. I'm now able to start a basic spring boot 3.3.4 application over java 17 with nginx unit.
Changing all references from javax.servlet to Jakarta.servlet is not the major problem, even if some deprecated methods does not exist anymore. ClassGraph library encounter some problem to list classes in the extracted war because of java module system. I had to create a module-info.java that references dependencies in unit java jar. My spring java application also now have to care about module requirements.
Some minor changes were also needed in makefile / autoconf to split classpath and modulepath, more jars needed at compile time because of "requires" declaration on unit jar.
The major issue I encountered is that sometimes, when I call PUT rest endpoint to load my application war, the process to load the application freeze, sometimes before extracting the war, sometimes just after extracting it... no clue why.
I have to kill the "prototype" and "application" process, kill the main unit process, rm the config.json in state dir, rm all references to module-info classes and extracted webapp directory in $TMPDIR, then try again ...
Changes made : https://github.com/nginx/unit/compare/master...gdufrene:unit:fix/spring3
Many TODOs to resolve around WebSocket and Multipart
best regards.
@gdufrene that branch looks fantastic; are you planning to continue working on it and propose a pull request here? We'd gladly review it or try to assist in debugging.
On Unit 1.29.1 - Java17 - Docker
eclipse-temurin:17-jdk-jammy
It is not possible to load a SpringBoot application version >=3.0. Unit did not crash. It simply isn't loading the Spring Application context. The log initially shows:
Sending request to the
HelloWorldController
which should answer with a niceHello from Spring on Unit!
is displaying a directory index likeStarting
unitd
in debug mode shows the reason:As Spring >= requires Tomcat10 with Servlet 5 it is not longer compatible with Units Servlet Implementation. Looking at the Changes from Apache Tomcat 8 to 10 shows that they moved from
javax
tojakarta
.It would be necessary to implement a new Servlet Spec to be able to load the Context of the newer generation of Spring Boot applications for example.
Please consider this issue as documentation only - we are not in a hurry to fix this for now. I just wanted to find a place to document my findings.
An application to reproduce is attached.
spring3-0.0.1-SNAPSHOT.war.zip
The unit configuration