Skip to content
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

Compilation fails when using reflection-config in quarkus 1.6.x #11184

Closed
killerzwelch opened this issue Aug 4, 2020 · 13 comments · Fixed by #11649
Closed

Compilation fails when using reflection-config in quarkus 1.6.x #11184

killerzwelch opened this issue Aug 4, 2020 · 13 comments · Fixed by #11649
Labels
env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@killerzwelch
Copy link

killerzwelch commented Aug 4, 2020

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(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

@killerzwelch killerzwelch added the kind/bug Something isn't working label Aug 4, 2020
@geoand
Copy link
Contributor

geoand commented Aug 4, 2020

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

@jaikiran
Copy link
Member

jaikiran commented Aug 4, 2020

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

@jaikiran
Copy link
Member

jaikiran commented Aug 4, 2020

The closest thing that I can remember to this, is this change #5458 but that happened in 1.1.x days, so not sure if that's related to the issue you are seeing.

@jaikiran jaikiran added the env/windows Impacts Windows machines label Aug 4, 2020
@killerzwelch
Copy link
Author

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.

@tapaniantonrundgren
Copy link

tapaniantonrundgren commented Aug 24, 2020

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)

@jaikiran
Copy link
Member

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

@tapaniantonrundgren
Copy link

It is with container build. Need to build Linux images

@jaikiran
Copy link
Member

I've opened #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)

@gsmet gsmet added this to the 1.8.0 - master milestone Aug 27, 2020
@tapaniantonrundgren
Copy link

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

@gsmet gsmet modified the milestones: 1.8.0 - master, 1.7.2.Final Sep 1, 2020
@killerzwelch
Copy link
Author

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

@jaikiran
Copy link
Member

jaikiran commented Sep 9, 2020

Thank you both for confirming the fix.

@manodupont
Copy link

manodupont commented Nov 5, 2020

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: oracle/graal#926

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

@onrclk
Copy link

onrclk commented Apr 21, 2022

unfortunately, i have also similar problem on Quarkus 1.11.1.Final version. i'm trying to build Quarkus app as native. But i'm getting following errors.

quarkus.native.container-build=true
quarkus.native.builder-image=quay.io/quarkus/ubi-quarkus-mandrel:20.3-java11
quarkus.native.native-image-xmx=10g
quarkus.native.resources.includes=arial-mt-bold.ttf,arialmt.ttf,reflect-config.json,resource-config.json
quarkus.native.additional-build-args=--initialize-at-run-time=org.apache.pdfbox.pdmodel.encryption.PublicKeySecurityHandler,\
-H:+RemoveSaturatedTypeFlows,\
-H:ResourceConfigurationFiles=resource-config.json,\
-H:ReflectionConfigurationFiles=reflect-config.json

[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] Running Quarkus native-image plugin on GraalVM Version 20.3.3.0-Final (Mandrel Distribution) (Java Version 11.0.12+7)[INFO] [io.quarkus.deployment.pkg.steps.NativeImageBuildStep] docker run -v //doc-builder/target/fqcs-doc-builder-1.3.4-SNAPSHOT-native-image-source-jar:/project:z --env LANG=C --rm quay.io/quarkus/ubi-quarkus-mandrel:20.3-java11 -J-Dsun.nio.ch.maxUpdateArraySize=100 -J-Djava.util.logging.manager=org.jboss.logmanager.LogManager -J-DCoordinatorEnvironmentBean.transactionStatusManagerEnable=false -J-Dio.netty.leakDetection.level=DISABLED -J-Dio.netty.allocator.maxOrder=1 -J-Duser.language=en -J-Dfile.encoding=UTF-8 --initialize-at-run-time=org.apache.pdfbox.pdmodel.encryption.PublicKeySecurityHandler -H:+RemoveSaturatedTypeFlows -H:ResourceConfigurationFiles=resource-config.json -H:ReflectionConfigurationFiles=reflect-config.json --initialize-at-build-time= -H:InitialCollectionPolicy=com.oracle.svm.core.genscavenge.CollectionPolicy$BySpaceAndTime -H:+JNI -H:+AllowFoldMethods -jar doc-builder-1.3.4-SNAPSHOT-runner.jar -H:FallbackThreshold=0 -H:+ReportExceptionStackTraces -J-Xmx10g -H:-AddAllCharsets -H:EnableURLProtocols=http,https --enable-all-security-services -H:-UseServiceLoaderFeature -H:+StackTrace doc-builder-1.3.4-SNAPSHOT-runner
Error: Invalid Path entry reflect-config.json
Caused by: java.nio.file.NoSuchFileException: /project/reflect-config.json

i've put files on https://github.com/danfickle/openhtmltopdf-native/tree/main/src/main/resources/META-INF/native-image (resources) under src/main/resources and src/main/resources/META-INF/native-image. But somehow does not work..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants