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

quarkus-logging-json not working with native images #8855

Closed
xtermi2 opened this issue Apr 25, 2020 · 3 comments · Fixed by #8857
Closed

quarkus-logging-json not working with native images #8855

xtermi2 opened this issue Apr 25, 2020 · 3 comments · Fixed by #8857
Assignees
Labels
area/logging kind/bug Something isn't working
Milestone

Comments

@xtermi2
Copy link

xtermi2 commented Apr 25, 2020

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:

  1. Create a project and add quarkus-logging-json e.g. this zip / configuration
  2. build the application with ./mvnw clean verify -Pnative -Dquarkus.native.container-build=true
  3. The NativeExampleResourceIT will fail with the above Exception.
  4. when starting the app with ./target/code-with-quarkus-1.0.0-SNAPSHOT-runner you will get the same Exception

Environment:

  • Output of uname -a or ver: Linux xxx 5.3.0-46-generic Arc - support initializer injection on superclasses #38-Ubuntu SMP Fri Mar 27 17:37:05 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Output of java -version: openjdk version "11.0.7" 2020-04-14
    OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu219.10)
    OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu219.10, mixed mode, sharing)
  • GraalVM version (if different from Java): no local installation, used the dockerized approach
  • Quarkus version or git rev: 1.3.2.Final
  • Build tool (ie. output of mvnw --version or gradlew --version): Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
@xtermi2 xtermi2 added the kind/bug Something isn't working label Apr 25, 2020
@machi1990 machi1990 changed the title quarkus-logging-json now working with native images quarkus-logging-json not working with native images Apr 25, 2020
@machi1990 machi1990 self-assigned this Apr 25, 2020
@machi1990
Copy link
Member

@xtermi2 thanks for reporting. I'll have a look, might be an easy fix.

machi1990 added a commit to machi1990/quarkus that referenced this issue Apr 25, 2020
add jsonp-deployment module in logging-json deployment module so that JsonProviderImpl is registered for reflection.

Fixes quarkusio#8855
@xtermi2
Copy link
Author

xtermi2 commented Apr 27, 2020

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.

@machi1990
Copy link
Member

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).

@gsmet gsmet added this to the 1.4.2.Final milestone Apr 30, 2020
gsmet pushed a commit to gsmet/quarkus that referenced this issue May 1, 2020
add jsonp-deployment module in logging-json deployment module so that JsonProviderImpl is registered for reflection.

Fixes quarkusio#8855
gwenneg pushed a commit to gwenneg/quarkus that referenced this issue May 2, 2020
add jsonp-deployment module in logging-json deployment module so that JsonProviderImpl is registered for reflection.

Fixes quarkusio#8855
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/logging kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants