Open aalmiray opened 3 years ago
Did you look at https://helidon.io/docs/v2/#/se/guides/37_jlink_image ?
I.e mvn package -Pjlink-image
@romain-grecourt Yes, I did. It does not solve my problem as this is not a Jlink issue. The application created using the helidon-quickstart-se
is not modular per se, as it does not define a module-info.java
file. There are no indications that the application JAR's manifest has an Automatic-Module-Name
entry either; nor there are instructions to run the application in a modular fashion (using the modulepath).
Helidon libraries are intended for use in microservices with a single classloader (and for JPMS a single module layer). Our module info files work with JPMS (there are several integration tests validating this both for SE and MP). When running in multiple classloader or module layers, the result is undefined.
@aalmiray - can you please describe the use case that requires multiple module layers in a microservice? That would help us to better classify this issue.
Thanks!
@tomas-langer sure, I can add more detail but first just to clarify, I'm not saying Helidon does not work with the Java Platform Module System at all, just that the ModuleLayer feature may not be supported at the moment, for good reasons.
I'm currently researching how Helidon could be used to construct an application that may have part of its behavior added/removed at runtime yet remain modular. This is a feature provided by Layrry because of its usage of ModuleLayer and a single classloader per layer.
We have an example of a simple vert.x app for which additjonal http routes become a available when a plugin is added at runtime. I thought I could replicate it with Helidon SE.
I am not sure that could work - WebServer is created and then "set in stone" - there is no way to mutate it at runtime. If you wanted to add/remove routes, you would need to stop it and create from scratch every time you want to update routing.
This PR contains an example of an SE application with module-info.java
: https://github.com/oracle/helidon/pull/2526/files
Understood. The example with WebServer is to demonstrate comparable behavior using plugin capabilities provided by Layrry. If Helidon's WebServer cannot have its routes mutated after the fact then that's alright, I'm not advocating for that to change. What I want is to test out Layrry's two main visible features in conjunction with Helidon:
If these features sound familiar is because they are (among others) provided by the OSGi spec however Layrry is much simpler than that.
Environment Details
Problem Description
Running a modular Helidon SE application in combination with ModuleLayer results in errors in some cases or a partly configured application in others. It appears that the Helidon codebase (while it provides full modules) does not take into account the possibility of
ModuleLayer
being in use by the application developer.Steps to reproduce
$ git clone https://github.com/moditect/layrry.git
1.3$ cd layrry
1.4$ mvn install
1.5 Alternartively you can download the latest release from https://github.com/moditect/layrry/releases/tag/v1.0.0.Alpha1 or install it via sdkman.Add a module descriptor to
src/main/java
$ mvn install
.txt
extension)$ <larry_dir>/layrry-launcher/target/distributions/layrry-launcher-1.0.0-SNAPSHOT-dist/layrry-launcher-1.0.0-SNAPSHOT/bin/layrry --layers-config layers-single.toml
This results in the following output
Notice that the application is running but some of its features failed to load.
.txt
extension)$ <larry_dir>/layrry-launcher/target/distributions/layrry-launcher-1.0.0-SNAPSHOT-dist/layrry-launcher-1.0.0-SNAPSHOT/bin/layrry --layers-config layers.toml
This results in an exception during launch:
Layrry configures a classloader per ModuleLayer, assembling a hierarchy of layers.