Quarkus: Compilation fails when using reflection-config in quarkus 1.6.x

Created on 4 Aug 2020  路  12Comments  路  Source: quarkusio/quarkus

Hi, I'm currently facing a strange problem when using quarkus 1.6.x
Describe the bug
I have a utility jar with lots of enums that I need to mention in a reflection config json file, as mentioned https://quarkus.io/guides/writing-native-applications-tips#registering-for-reflection

in my application.properties I have the line
quarkus.native.additional-build-args =-H:ReflectionConfigurationFiles=reflection-config.json

The file 'reflection-config.json' is located in src/main/resources
Issue appears when trying to create a native executable. It does not matter if I use the docker container or a local installed graalvm.

Expected behavior
Expectation is that the application compiles.

Actual behavior
The compilation failes with the following error

[INFO] --- quarkus-maven-plugin:1.6.1.Final:build (default) @ product-endpoint-quarkus ---
[INFO] [org.jboss.threads] JBoss Threads version 3.1.1.Final
[WARNING] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Uber JAR strategy is used for native image source JAR generation on Windows. This is done for the time being to work around a current GraalVM limitation on Windows concerning the maximum command length (see https://github.com/oracle/graal/issues/2387).
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building fat jar: D:\users\killerzwelch\IdeaProjects\connect\product-endpoint\product-endpoint-quarkus\target\product-endpoint-quarkus-0.4-SNAPSHOT-native-image-source-jar\product-endpoint-quarkus-0.4-SNAPSHOT-runner.jar
[WARNING] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Duplicate entry META-INF/LGPL-3.0.txt entry from com.github.fge:msg-simple::jar:1.1(compile) will be ignored. Existing file was provided by com.github.fge:btf::jar:1.2(compile)
[WARNING] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Duplicate entry META-INF/ASL-2.0.txt entry from com.github.fge:msg-simple::jar:1.1(compile) will be ignored. Existing file was provided by com.github.fge:btf::jar:1.2(compile)
[WARNING] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Duplicate entry META-INF/LGPL-3.0.txt entry from com.github.fge:jackson-coreutils::jar:1.6(compile) will be ignored. Existing file was provided by com.github.fge:btf::jar:1.2(compile)
[WARNING] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Duplicate entry META-INF/ASL-2.0.txt entry from com.github.fge:jackson-coreutils::jar:1.6(compile) will be ignored. Existing file was provided by com.github.fge:btf::jar:1.2(compile)
[WARNING] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Duplicate entry META-INF/LGPL-3.0.txt entry from com.github.fge:json-patch::jar:1.9(compile) will be ignored. Existing file was provided by com.github.fge:btf::jar:1.2(compile)
[WARNING] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Duplicate entry META-INF/ASL-2.0.txt entry from com.github.fge:json-patch::jar:1.9(compile) will be ignored. Existing file was provided by com.github.fge:btf::jar:1.2(compile)
[WARNING] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Dependencies with duplicate files detected. The dependencies [com.github.fge:jackson-coreutils::jar:1.6(compile), com.github.fge:msg-simple::jar:1.1(compile), com.github.fge:btf::jar:1.2(compile), com.github.fge:json-patch::jar:1.9(compile)] contain duplicate files, e.g. META-INF/ASL-2.0.txt
[WARNING] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Dependencies with duplicate files detected. The dependencies [com.sun.activation:jakarta.activation::jar:1.2.1(compile), jakarta.activation:jakarta.activation-api::jar:1.2.1(compile)] contain duplicate files, e.g. javax/activation/ActivationDataFlavor.class
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Building native image from D:\users\killerzwelch\IdeaProjects\connect\product-endpoint\product-endpoint-quarkus\target\product-endpoint-quarkus-0.4-SNAPSHOT-native-image-source-jar\product-endpoint-quarkus-0.4-SNAPSHOT-runner.jar
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Checking image status quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java11
20.1.0-java11: Pulling from quarkus/ubi-quarkus-native-image
Digest: sha256:abff65d7807d2bc68fd9835748cbfc5066a7a4b76f984c60cb2170ed1d4412c8
Status: Image is up to date for quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java11
quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java11
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 20.1.0 (Java Version 11.0.7)
[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] docker run -v //d/users/killerzwelch/IdeaProjects/connect/product-endpoint/product-endpoint-quarkus/target/product-endpoint-quarkus-0.4-SNAPSHOT-native-image-source-jar:/project:z --env LANG=C --rm quay.io/quarkus/ubi-quarkus-native-image:20.1.0-java11 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize=true -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 -J-Duser.language=de -J-Dfile.encoding=UTF-8 -H:ReflectionConfigurationFiles=reflection-config.json --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -H:+JNI -jar product-endpoint-quarkus-0.4-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:-IncludeAllTimeZones -H:EnableURLProtocols=http,https --enable-all-security-services -H:-UseServiceLoaderFeature -H:+StackTrace product-endpoint-quarkus-0.4-SNAPSHOT-runner
Error: Invalid Path entry reflection-config.json
Caused by: java.nio.file.NoSuchFileException: /project/reflection-config.json
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  19.369 s
[INFO] Finished at: 2020-08-04T08:21:40+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus:quarkus-maven-plugin:1.6.1.Final:build (default) on project product-endpoint-quarkus: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkus.deployment.pkg.steps.NativeImageBuildStep#build threw an exception: java.lang.RuntimeException: Failed to build native image
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:371)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$2.execute(ExtensionLoader.java:932)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:277)
[ERROR]         at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:2046)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1578)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1452)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:834)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:479)
[ERROR] Caused by: java.lang.RuntimeException: Image generation failed. Exit code: 1
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.imageGenerationFailed(NativeImageBuildStep.java:421)
[ERROR]         at io.quarkus.deployment.pkg.steps.NativeImageBuildStep.build(NativeImageBuildStep.java:349)
[ERROR]         ... 12 more
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

when using my local graalvm I get the same exception, only the path is different of the path that cannot be found

To Reproduce
Steps to reproduce the behavior:

  1. create a reflection-properties.json
  2. reference this file with quarkus.native.additional-build-args =-H:ReflectionConfigurationFiles=reflection-config.json in the application.properties
  3. execute mvnw -Pnative

Configuration

# Add your application.properties here, if applicable.
activemq.messages.timeToLiveMs=30000
quarkus.artemis.url=tcp://activemq-artemis-activemq-artemis.default:61616
quarkus.artemis.username=quarkus
quarkus.artemis.password=quarkus

quarkus.http.port=8080

quarkus.native.additional-build-args =-H:ReflectionConfigurationFiles=reflection-config.json

quarkus.log.handler.gelf.enabled=true
quarkus.log.handler.gelf.host=logstash.elasticsearch
quarkus.log.handler.gelf.port=12201

quarkus.jaeger.service-name=product-endpoint
quarkus.jaeger.sampler-type=const
quarkus.jaeger.sampler-param=1
quarkus.log.console.format=%d{HH:mm:ss} %-5p traceId=%X{traceId}, spanId=%X{spanId}, sampled=%X{sampled} [%c{2.}] (%t) %s%e%n

quarkus.index-dependency.ifsfmodel.group-id=com.company
quarkus.index-dependency.ifsfmodel.artifact-id=model

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment (please complete the following information):

  • Output of uname -a or ver:
    Microsoft Windows [Version 10.0.18362.592]
  • Output of java -version:
    ```java version "11.0.6" 2020-01-14 LTS
    Java(TM) SE Runtime Environment 18.9 (build 11.0.6+8-LTS)
    Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.6+8-LTS, mixed mode)
 - GraalVM version (if different from Java): 

openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 11.0.7+10-jvmci-20.1-b02, mixed mode, sharing)

 - Quarkus version or git rev: 
1.6.1.Final
 - Build tool (ie. output of `mvnw --version` or `gradlew --version`): 

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: D:\Users\killerzwelch.m2\wrapper\dists\apache-maven-3.6.3-bin\1iopthnavndlasol9gbrbg6bf2\apache-maven-3.6.3
Java version: 11.0.6, vendor: Oracle Corporation, runtime: D:\jdk-11.0.6
Default locale: de_DE, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
```
Additional context
The application compiles without any problem when using quarkus < 1.6.x

enwindows kinbug

Most helpful comment

Hi, due to proxy restrictions I am unable to test the SNAPSHOT release, but I can confirm that the problem is solved in version 1.7.2.Final for me. Thanks a lot for analysing and fixing

All 12 comments

On Linux, I could not reproduce either when building the native binary either with docker or without

There have been similar issues reported previously for native image build on Windows with Docker. Do any of the suggestions in this other issue https://github.com/quarkusio/quarkus/issues/6259 help? Having said that I can't say why it was working fine in versions lesser than 1.6.x of Quarkus.

The closest thing that I can remember to this, is this change https://github.com/quarkusio/quarkus/pull/5458 but that happened in 1.1.x days, so not sure if that's related to the issue you are seeing.

Thanks for reply. I will have a deeper look and try to reproduce it there. On additional info - when I don't mention the json file the package builds. So the runner.jar is mounted correctly into the container and native image is build.

I have this same issue with Windows 10 and quarkus versions 1.6.0 and later. Works with quarkus 1.5.2 and on Ubuntu with WSL2 with all Quarkus versions (in my case the file is resources-config.json that is not found)

Hello @tapaniantonrundgren, is it with a (docker) container build of native-image (using -Dquarkus.native.container-build=true) or just regular non-container build?

It is with container build. Need to build Linux images

I've opened https://github.com/quarkusio/quarkus/pull/11649 with a potential fix. If anyone of you can verify that change works for you, that would be great.

This doc might help https://github.com/quarkusio/quarkus/blob/master/CONTRIBUTING.md#checking-an-issue-is-fixed-in-master (just use my PR branch instead of master)

Used the latest 999-SNAPSHOT and yes, the native container build now works on Windows 10 too

Hi, due to proxy restrictions I am unable to test the SNAPSHOT release, but I can confirm that the problem is solved in version 1.7.2.Final for me. Thanks a lot for analysing and fixing

Thank you both for confirming the fix.

I am using 1.9.1.Final and i still have that error.

Here is my config

quarkus:
   native:
    additional-build-args: -H:ResourceConfigurationFiles=resources-config.json \
      -H:+ReportUnsupportedElementsAtRuntime \
      -no-server \
      --allow-incomplete-classpath \
      --rerun-class-initialization-at-runtime=javax.net.ssl.SSLContext \
      -H:-UseServiceLoaderFeature \
      --enable-all-security-services \
      -H:ConfigurationFileDirectories=config-dir \
      -H:EnableURLProtocols=http,https

this won't build and give the error:

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] docker run -v /Users/manueldupont/cjl-scheduler/target/cjl-api-scheduler-1.0.0-SNAPSHOT-native-image-source-jar:/project:z --env LANG=C --rm quay.io/quarkus/ubi-quarkus-native-image:20.2.0-java11 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-DCoordinatorEnvironmentBean.transactionStatusManagerEnable=false -J-Dvertx.logger-delegate-factory-class-name=io.quarkus.vertx.core.runtime.VertxLogDelegateFactory -J-Dvertx.disableDnsResolver=true -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 -J-Drx.unsafe-disable=true -J-Duser.language=en -J-Dfile.encoding=UTF-8 -H:ResourceConfigurationFiles=classes/resources-config.json  -H:+ReportUnsupportedElementsAtRuntime  --no-server  --allow-incomplete-classpath  --rerun-class-initialization-at-runtime=javax.net.ssl.SSLContext  -H:-UseServiceLoaderFeature  --enable-all-security-services  -H:ConfigurationFileDirectories=config-dir  -H:EnableURLProtocols=http https --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy\$BySpaceAndTime -H:+JNI -jar cjl-api-scheduler-1.0.0-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -H:-AddAllCharsets -H:EnableURLProtocols=http,https --enable-all-security-services --no-server -H:-UseServiceLoaderFeature -H:+StackTrace cjl-api-scheduler-1.0.0-SNAPSHOT-runner
Error: Invalid Path entry classes/resources-config.json  -H:+ReportUnsupportedElementsAtRuntime  --no-server  --allow-incomplete-classpath  --rerun-class-initialization-at-runtime=javax.net.ssl.SSLContext  -H:-UseServiceLoaderFeature  --enable-all-security-services  -H:ConfigurationFileDirectories=config-dir  -H:EnableURLProtocols=http
Caused by: java.nio.file.NoSuchFileException: /project/classes/resources-config.json  -H:+ReportUnsupportedElementsAtRuntime  --no-server  --allow-incomplete-classpath  --rerun-class-initialization-at-runtime=javax.net.ssl.SSLContext  -H:-UseServiceLoaderFeature  --enable-all-security-services  -H:ConfigurationFileDirectories=config-dir  -H:EnableURLProtocols=http
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE

Previously, to be able to build, i would have only this config

quarkus:
   native:
    additional-build-args: -H:ResourceConfigurationFiles=resources-config.json

That conf build a native image no problem. BUT, it will fail at runtime cause of some google cloud API library.

Caused by: java.lang.InstantiationException: Type `com.google.api.client.json.GenericJson` can not be instantiated reflectively as it does not have a no-parameter constructor or the no-parameter constructor has not been added explicitly to the native image.
    at java.lang.Class.newInstance(DynamicHub.java:850)
    at com.google.api.client.util.Types.newInstance(Types.java:113)
    ... 64 more

Thats why i am trying to configure the native image differently with all those flags as seen here: https://github.com/oracle/graal/issues/926

But i just can't build a native image with that fix.

Was this page helpful?
0 / 5 - 0 ratings