-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for creating native image with GraalVM #2974
Comments
As far as I know, Jersey (and HK2) aren't supporting Graal native images at the moment. |
It looks like Dropwizard uses SPI in a way it wasn't intended to be used. When building native image, GraalVM will try to create instances of all classes that implement SPI interfaces, as described in https://github.com/oracle/graal/blob/92f0b657a5f4892f7380517a714bf93d13db2530/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ServiceLoaderFeature.java#L79 It means that for an SPI interface There are other interfaces that extend Jersey should be working now oracle/graal#846. |
This bug is definitely worth fixing. With Graal we could distribute a Dropwizard app as a native binary, eliminating the need for a shaded jar file. It would even eliminate the need to install a jvm on a target system. |
I tried to build a native image of Dropwizard 2.0 with GraalVM CE 19.3.1 with Java 11. The source code is available at https://github.com/meshuga/dropwizard-graal. To overcome the error described above, I turned off
With the feature turned off, I was able to build a native image within 2-4 minutes (on MacBook Pro 2017) with outcoming binary having 27 MB but get a startup error when initializing Hibernate Validator and Joda Time:
I think after all, it's possible to make Dropwizard run as native image (with narrowed configuration e.g. HTTP only). The compilation time will be biggest issue here since the framework has a lot of transitive dependencies but I think with time, the compilation time of GraalVM will be improved. Technically, the biggest challenge will be to provide proper support for Jersey and HK2, as @joschi mentioned. |
I see something about HK2 mentioned here. |
If Jersey is the limiting factor, then that just goes back to my rant on #1463 |
@OneCricketeer, @meshuga I wonder if you have any updates on it? |
I'm no longer working on projects that involve Dropwizard, thus will be hard to test things out on production-like systems. I checked the timeline of the Jersey roadmap for GraalVM support and it looks like it should be supported in release 2.34 - https://github.com/eclipse-ee4j/jersey/wiki/Road-Map - fingers crossed! Once done, it should be possible to adjust Dropwizard to create native images. JDBI seems to work with native images (jdbi/jdbi#1797), same with Hibernate (https://in.relation.to/2020/02/14/hibernate-orm-5-4-12/) |
Graal VM support moved to Jersey 2.35. |
@trnl Do you know any issue/jira created on jersey side related to this so that we can follow up on an ETA? I could not find any. |
@subash89 The jersey side issue is: eclipse-ee4j/jersey#4547. It appears that basic graalvm support was added in Jersey 2.35. See: https://github.com/eclipse-ee4j/jersey/blob/master/docs/src/main/docbook/graalvm-native-image.xml. |
Unfortunately, the support for |
This issue is stale because it has been open 90 days with no activity. Remove the "stale" label or comment or this will be closed in 14 days. |
@joschi, can you please reopen the issue? It is still very relevant and actually a big downside for Dropwizard in comparison with other frameworks. |
@trnl Would you be willing to work on the issue if we reopen it? Looking at the effort it takes for Quarkus, Micronaut, and Spring Native to work properly with GraalVM Native Image, I don't think that we (@dropwizard/committers) will work on it anytime soon. |
@joschi can you elaborate more on the efforts or point out where I can find more information about it? |
@trnl The existence of Spring Native itself, https://info.michael-simons.eu/2020/09/15/about-the-tooling-available-to-create-native-graalvm-images/, https://www.salvis.com/blog/2021/12/29/graalvm-native-image-first-impressions/, etc. At least I am not willing and able to spend that much time on this. |
Short update: I'm currently testing on the |
Is there any update on this particular support for GraalVM with Dropwizard? |
Hibernate team only focuses on supporting Hibernate with Quarkus but it looks like Hibernate 6 works with graalvm, just need to provide configurations in SPI. |
Did anyone tried creating native image with GraalVm ? I tried with following Dockerfile
and got this error
The text was updated successfully, but these errors were encountered: