Describe the bug
When adding quarkus-logging-json dependency, building a native image is still working, but when starting the native image I get this exception and the application exits:
$ ./target/code-with-quarkus-1.0.0-SNAPSHOT-runner
Exception in thread "main" java.lang.RuntimeException: Failed to start quarkus
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:240)
at io.quarkus.runtime.Application.start(Application.java:90)
at io.quarkus.runtime.Application.run(Application.java:228)
at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:41)
Caused by: javax.json.JsonException: Provider org.glassfish.json.JsonProviderImpl could not be instantiated: java.lang.InstantiationException: Type `org.glassfish.json.JsonProviderImpl` 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 javax.json.spi.JsonProvider.provider(JsonProvider.java:78)
at javax.json.Json.createGeneratorFactory(Json.java:154)
at org.jboss.logmanager.formatters.JsonFormatter.<init>(JsonFormatter.java:60)
at io.quarkus.logging.json.runtime.LoggingJsonRecorder.initializeJsonLogging(LoggingJsonRecorder.java:17)
at io.quarkus.deployment.steps.LoggingJsonSteps$setUpFormatter8.deploy_0(LoggingJsonSteps$setUpFormatter8.zig:57)
at io.quarkus.deployment.steps.LoggingJsonSteps$setUpFormatter8.deploy(LoggingJsonSteps$setUpFormatter8.zig:82)
at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:82)
... 3 more
Caused by: java.lang.InstantiationException: Type `org.glassfish.json.JsonProviderImpl` 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:796)
at javax.json.spi.JsonProvider.provider(JsonProvider.java:73)
... 9 more
Expected behavior
native application starts without errors.
To Reproduce
Steps to reproduce the behavior:
quarkus-logging-json e.g. this zip / configuration./mvnw clean verify -Pnative -Dquarkus.native.container-build=trueNativeExampleResourceIT will fail with the above Exception../target/code-with-quarkus-1.0.0-SNAPSHOT-runner you will get the same ExceptionEnvironment:
uname -a or ver: Linux xxx 5.3.0-46-generic #38-Ubuntu SMP Fri Mar 27 17:37:05 UTC 2020 x86_64 x86_64 x86_64 GNU/Linuxjava -version: openjdk version "11.0.7" 2020-04-14mvnw --version or gradlew --version): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)@xtermi2 thanks for reporting. I'll have a look, might be an easy fix.
Thx. I can confirm that adding
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonp-deployment</artifactId>
<version>${quarkus.platform.version}</version>
</dependency>
will fix the issue - as a workaround until the dependency is delivered transitively.
Great thanks for checking.
You can also temporarily fix the issue by adding:
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jsonp</artifactId>
</dependency>
as you don't need to add the deployment module in your app (unless otherwise it is compile only scope).