container icon indicating copy to clipboard operation
container copied to clipboard

Explicitly required module ALL-MODULE-PATH is not available

Open fipro78 opened this issue 1 year ago • 6 comments

When trying to build a native image with graalvm-ce-java17-22.2.0 and the following options:

${GRAALVM_HOME}\bin\native-image \
--no-fallback \
--module-path ${LIB_FOLDER} \
--add-modules ALL-MODULE-PATH \
--module ${MAIN_MODULE} \
-H:ConfigurationFileDirectories=META-INF\native-image \
-H:+ReportUnsupportedElementsAtRuntime \
-H:+ReportExceptionStackTraces

I get the following error:

Fatal error: com.oracle.svm.core.util.VMError$HostedError: Explicitly required module ALL-MODULE-PATH is not available
        at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:68)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.ModuleLayerFeature.lambda$afterAnalysis$2(ModuleLayerFeature.java:160)
        at java.base/java.lang.Iterable.forEach(Iterable.java:75)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.ModuleLayerFeature.afterAnalysis(ModuleLayerFeature.java:157)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.lambda$runPointsToAnalysis$12(NativeImageGenerator.java:752)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.FeatureHandler.forEachFeature(FeatureHandler.java:78)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.runPointsToAnalysis(NativeImageGenerator.java:752)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:564)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:521)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:407)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:585)
        at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)

Is the add-modules option not supported in native-image? Or is the option ALL_MODULE_PATH not supported? The native-image help shows that the option as well as the value should be working.

fipro78 avatar Sep 22 '22 05:09 fipro78

Hi, Thank you for reporting this, we'll take a look into it and get back to you

oubidar-Abderrahim avatar Sep 26 '22 10:09 oubidar-Abderrahim

Is it possible to provide a reproducer for this issue?

oubidar-Abderrahim avatar Sep 27 '22 10:09 oubidar-Abderrahim

Yes I will provide a reproducer that I can share. Just need some time to cleanup and push to my GitHub account.

fipro78 avatar Sep 27 '22 11:09 fipro78

Instead of preparing the GitHub repo (need some time to get everything ready) I have attached the sample in the archive file.

native.zip

Without the option --add-modules ALL-MODULE-PATH it seems the resulting image is missing some resources. You can see this when you start the executable as there will be an exception and some warnings about missing resources.

I also noticed that the classpath option is not working as expected.

  1. --class-path atomos_lib/*

=> Error: Unknown arguments: atomos_lib/configurable-1.0.0-SNAPSHOT.jar, atomos_lib/eventhandler-1.0.0-SNAPSHOT.jar, atomos_lib/impl-1.0.0-SNAPSHOT.jar, atomos_lib/org.apache.felix.atomos-1.0.0.jar, atomos_lib/org.apache.felix.configadmin-1.9.24.jar, atomos_lib/org.apache.felix.gogo.command-1.1.2.jar, atomos_lib/org.apache.felix.gogo.runtime-1.1.6.jar, atomos_lib/org.apache.felix.gogo.shell-1.1.4.jar, atomos_lib/org.apache.felix.scr-2.2.0.jar, atomos_lib/org.eclipse.equinox.event-1.6.100.jar, atomos_lib/org.eclipse.osgi-3.17.200.jar, atomos_lib/org.osgi.namespace.implementation-1.0.0.jar, atomos_lib/org.osgi.service.event-1.4.1.jar, atomos_lib/org.osgi.util.function-1.2.0.jar, atomos_lib/org.osgi.util.promise-1.2.0.jar, atomos_lib/osgi.annotation-8.1.0.jar, atomos_lib/osgi.core-8.0.0-AtomosEquinox.jar, org.apache.felix.atomos.Atomos

  1. --class-path atomos_lib/ or --class-path atomos_lib

=>

Error: Main entry point class 'org.apache.felix.atomos.Atomos' neither found on the classpath nor on the modulepath.
classpath: '${PROJECT_DIR}\atomos_lib'
modulepath: '${GRAALVM_HOME}\lib\svm\library-support.jar'

The only option that works is to list every jar explicitly in the --class-path option with the corresponding separator (; on Windows and : on Linux).

fipro78 avatar Sep 27 '22 13:09 fipro78

In the shared zip, I see 2 folders, one with generated config and the other with multiple jars. Could you please specify the steps to reproduce this issue?

oubidar-Abderrahim avatar Oct 11 '22 15:10 oubidar-Abderrahim

  1. Unzip the shared zip in a directory (e.g. test)
  2. Open a commandline and switch to this directory
  3. Execute the following command:
${GRAALVM_HOME}\bin\native-image \
--no-fallback \
--module-path atomos_lib \
--add-modules ALL-MODULE-PATH \
--module org.apache.felix.atomos \
-H:ConfigurationFileDirectories=META-INF\native-image \
-H:+ReportUnsupportedElementsAtRuntime \
-H:+ReportExceptionStackTraces

fipro78 avatar Oct 13 '22 09:10 fipro78

This should be fixed in the new 22.3.0 release, could you please test it and confirm?

oubidar-Abderrahim avatar Oct 31 '22 10:10 oubidar-Abderrahim

The error is gone, but the result is not the same as with running the native-image build using the classpath. Starting the application shows an exception. It doesn't seem to be really relevant, but it is different. See https://github.com/apache/felix-atomos/issues/68

$GRAALVM_HOME/bin/native-image \
--no-fallback \
--initialize-at-build-time=org.apache.felix.service.command.Converter \
--module-path atomos_lib \
--add-modules ALL-MODULE-PATH \
--module org.apache.felix.atomos \
-H:ConfigurationFileDirectories=native-image-resources \
-H:+ReportUnsupportedElementsAtRuntime \
-H:+ReportExceptionStackTraces \
atomos

The classpath command that is working without issues is:

$GRAALVM_HOME/bin/native-image \
--no-fallback \
--initialize-at-build-time=org.apache.felix.service.command.Converter \
--class-path atomos_lib/api-1.0.0-SNAPSHOT.jar:atomos_lib/benchmark-1.0.0-SNAPSHOT.jar:atomos_lib/command-1.0.0-SNAPSHOT.jar:atomos_lib/configurable-1.0.0-SNAPSHOT.jar:atomos_lib/eventhandler-1.0.0-SNAPSHOT.jar:atomos_lib/impl-1.0.0-SNAPSHOT.jar:atomos_lib/org.apache.felix.atomos-1.0.0.jar:atomos_lib/org.apache.felix.configadmin-1.9.24.jar:atomos_lib/org.apache.felix.gogo.command-1.1.2.jar:atomos_lib/org.apache.felix.gogo.runtime-1.1.6.jar:atomos_lib/org.apache.felix.gogo.shell-1.1.4.jar:atomos_lib/org.apache.felix.scr-2.2.0.jar:atomos_lib/org.eclipse.equinox.event-1.6.100.jar:atomos_lib/org.eclipse.osgi-3.17.200.jar:atomos_lib/org.osgi.namespace.implementation-1.0.0.jar:atomos_lib/org.osgi.service.event-1.4.1.jar:atomos_lib/org.osgi.util.function-1.2.0.jar:atomos_lib/org.osgi.util.promise-1.2.0.jar:atomos_lib/osgi.annotation-8.1.0.jar:atomos_lib/osgi.core-8.0.0-AtomosEquinox.jar \
-H:ConfigurationFileDirectories=native-image-resources \
-H:+ReportUnsupportedElementsAtRuntime \
-H:+ReportExceptionStackTraces \
org.apache.felix.atomos.Atomos \
atomos

The application is a small Gogo Shell commandline application. You can for example enter modify Test and you will get some modified versions of the input printed to the console.

BTW, I am running the build on Windows 10 for the verification. Just in case this makes a difference. I updated the commands to Linux style to make it easier for you to reproduce it.

I also tried the following executions with the classpath option, that actually still don't work:

  1. classpath folder
$GRAALVM_HOME/bin/native-image \
--no-fallback \
--initialize-at-build-time=org.apache.felix.service.command.Converter \
--class-path atomos_lib \
-H:ConfigurationFileDirectories=native-image-resources \
-H:+ReportUnsupportedElementsAtRuntime \
-H:+ReportExceptionStackTraces \
org.apache.felix.atomos.Atomos \
atomos

Shows the following error:

Error: Main entry point class 'org.apache.felix.atomos.Atomos' neither found on the classpath nor on the modulepath.
classpath: 'xxx\graal_test\atomos_lib'
modulepath: '$GRAALVM_HOME\lib\svm\library-support.jar'
com.oracle.svm.core.util.UserError$UserException: Main entry point class 'org.apache.felix.atomos.Atomos' neither found on the classpath nor on the modulepath.
  1. classpath folder with asterisk
$GRAALVM_HOME/bin/native-image \
--no-fallback \
--initialize-at-build-time=org.apache.felix.service.command.Converter \
--class-path atomos_lib/* \
-H:ConfigurationFileDirectories=native-image-resources \
-H:+ReportUnsupportedElementsAtRuntime \
-H:+ReportExceptionStackTraces \
org.apache.felix.atomos.Atomos \
atomos

Shows the following error:

Error: Unknown arguments: atomos_lib\configurable-1.0.0-SNAPSHOT.jar, atomos_lib\eventhandler-1.0.0-SNAPSHOT.jar, atomos_lib\impl-1.0.0-SNAPSHOT.jar, atomos_lib\org.apache.felix.atomos-1.0.0.jar, atomos_lib\org.apache.felix.configadmin-1.9.24.jar, atomos_lib\org.apache.felix.gogo.command-1.1.2.jar, atomos_lib\org.apache.felix.gogo.runtime-1.1.6.jar, atomos_lib\org.apache.felix.gogo.shell-1.1.4.jar, atomos_lib\org.apache.felix.scr-2.2.0.jar, atomos_lib\org.eclipse.equinox.event-1.6.100.jar, atomos_lib\org.eclipse.osgi-3.17.200.jar, atomos_lib\org.osgi.namespace.implementation-1.0.0.jar, atomos_lib\org.osgi.service.event-1.4.1.jar, atomos_lib\org.osgi.util.function-1.2.0.jar, atomos_lib\org.osgi.util.promise-1.2.0.jar, atomos_lib\osgi.annotation-8.1.0.jar, atomos_lib\osgi.core-8.0.0-AtomosEquinox.jar, org.apache.felix.atomos.Atomos, atomos

fipro78 avatar Nov 03 '22 14:11 fipro78

As this seems to be a different problem, can you please create a new issue for it? this is not directly related to container so the appropriate place should be https://github.com/oracle/graal/issues I'll be closing this issue as resolved for now. Thank you.

oubidar-Abderrahim avatar Nov 07 '22 15:11 oubidar-Abderrahim