Graal: [native-image] Attempt to build native image that uses logback fails

Created on 5 Dec 2019  路  6Comments  路  Source: oracle/graal

I have put together a minimal example of a scala project built using sbt that uses logback that fails to compile to a native image. See the attached tar.gz file.

The error encountered is
[error] Fatal error: com.oracle.svm.core.util.VMError$HostedError: java.lang.NoClassDefFoundError: Lorg/codehaus/janino/ScriptEvaluator;
[error] at com.oracle.svm.core.util.VMError.shouldNotReachHere(VMError.java:70)
[error] at com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:636)

This is with the flags "--no-fallback", "--allow-incomplete-classpath", "--verbose"

It should be possible to make this native image without org.codehaus.janino.ScriptEvaluator being on the class path if --allow-incomplete-classpath command line option is used as in this case. The method name appearing in the stack trace of shouldNotReachHere makes me believe this is not an intentional failure scenario.

reproduced.tar.gz

native-image

Most helpful comment

As a work around, adding a dependency on Janino fixed this issue for me. I.e. adding the following sbt configuration:

libraryDependencies +=  "org.codehaus.janino" % "janino" % "3.1.0"

All 6 comments

I confirm this issue, have you the information if it was introduced on 19.3.0 ?

I've tested on 19.3.0

Yes it seems to have been introduced with 19.3.0. I could not reproduce the problem with graalvm-ce-linux-amd64-19.2.1.tar.gz as the image builds and runs successfully. I also tried graalvm-ce-java8-linux-amd64-19.3.0.tar.gz and it also shows the same VMError$HostedError: java.lang.NoClassDefFoundError as the java-11 variant of 19.3.0

confirmed - moving back to 19.2.1 eliminates the problem.

As a work around, adding a dependency on Janino fixed this issue for me. I.e. adding the following sbt configuration:

libraryDependencies +=  "org.codehaus.janino" % "janino" % "3.1.0"

Try adding --initialize-at-build-time=ch.qos.logback.core.boolex.JaninoEventEvaluatorBase if JaninoEventEvaluatorBase is on your classpath.

--allow-incomplete-classpath should now report the missing class at run time, if the code path is actually executed.

Was this page helpful?
0 / 5 - 0 ratings