Tomcat 10.0.14
Windows 10 x64 21H1 OS Build 19043.1415

openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment GraalVM CE 21.3.0 (build
17.0.1+12-jvmci-21.3-b05)
OpenJDK 64-Bit Server VM GraalVM CE 21.3.0 (build 17.0.1+12-jvmci-21.3-b05,
mixed mode, sharing)

NetBeans 12.6, maven webapp project
Maven 3.8.4
Ant 1.10.12

Followed guide at https://tomcat.apache.org/tomcat-10.0-doc/graal.html

Sorry in advance if not all issues should be reported here but instead are
graalvm native image related, I'm reporting everything here and on their
github fro completeness.

https://drive.google.com/file/d/17flFW5nlNCdojlvJxCOy23NJBj03p46u/view?usp=sharing
In this link you can find a folder with everything I used from tomcat
stuffed folder downloaded from the github link present in the tomcat AOT
guide, to all commands I put in a script for easier testing purpose, source
webapp, built webapp, screenshots, everything :D

I'll start by saying I'm well aware I could definitely have overlooked
something, anyway I managed to get to the final native image and it works,
BUT:

If you remove .class files from webapps/webappname folder, when you run the
binary file, it won't find those files, only jsps. This is strange because
those files are actually present in the fat jar, and this actually beats
the purpose of builidng a native image if you have to ship it with java
files.

If there is a class extending ServletContextListener (InitClass in this
webapp), when running command with "--catalina -generateCode" parameter,
where you have to access all jsps and servlets, the class extending
ServletContextListener will be initialized/used(?) like 2 times, but the
second time not completly, resetting everything done in the first
initialization.
In this webapp it happens when you access the only servlet present.
Anyway all code is in the google drive link and in InitClass i put some
prints so you can see what I mean.
In another bigger webapp my InitClass initializes a lot of things used by
the webapp basically screwing it.
This issues happens only in this phase becasue in the second phase where
the parameter is "useGeneratedCode" it works normally both with this simple
test webapp and in my other one

When building with native-image command, if
"-J--add-exports=java.management/sun.management=ALL-UNNAMED" isn't used as
additional parameter, errors will pop on run crashing the app. (screenshot
in the google drive link)

Reply via email to