snowdrop-zen / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
1 stars 0 forks source link

Native Image with Custom Config and OpenTracing #133

Closed snowdrop-bot closed 4 years ago

snowdrop-bot commented 4 years ago

Describe the bug There seems to be a weird combination between custom MP Config Source and Opentracing in Quarkus that fails to run the project in native mode.

Expected behavior Native image should run as normal.

Actual behavior Native image runs fails with:

ERROR: Failed to start application
java.util.ServiceConfigurationError: org.eclipse.microprofile.config.spi.ConfigSource: Provider org.jboss.resteasy.microprofile.config.ServletConfigSource could not be instantiated
    at java.util.ServiceLoader.fail(ServiceLoader.java:581)
    at java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:803)
    at java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:721)
    at java.util.ServiceLoader$3.next(ServiceLoader.java:1394)
    at java.lang.Iterable.forEach(Iterable.java:74)
    at io.smallrye.config.SmallRyeConfigBuilder.discoverSources(SmallRyeConfigBuilder.java:74)
    at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:175)
    at io.quarkus.runtime.generated.Config.readConfig(Config.zig:32805)
    at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(RuntimeConfigSetup.zig:38)
    at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:94)
    at io.quarkus.runtime.Application.start(Application.java:89)
    at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:90)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
    at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
Caused by: java.lang.RuntimeException: java.lang.InstantiationException: Type `org.jboss.resteasy.microprofile.config.ServletConfigSourceImpl` 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 org.jboss.resteasy.microprofile.config.BaseServletConfigSource.<init>(BaseServletConfigSource.java:26)
    at org.jboss.resteasy.microprofile.config.ServletConfigSource.<init>(ServletConfigSource.java:21)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:779)
    ... 14 more
Caused by: java.lang.InstantiationException: Type `org.jboss.resteasy.microprofile.config.ServletConfigSourceImpl` 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 org.jboss.resteasy.microprofile.config.BaseServletConfigSource.<init>(BaseServletConfigSource.java:23)
    ... 17 more

May 05, 2020 12:06:49 PM io.quarkus.runtime.ApplicationLifecycleManager run
ERROR: Error running Quarkus application
java.lang.RuntimeException: Failed to start quarkus
    at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:307)
    at io.quarkus.runtime.Application.start(Application.java:89)
    at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:90)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:61)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:38)
    at io.quarkus.runtime.Quarkus.run(Quarkus.java:106)
    at io.quarkus.runner.GeneratedMain.main(GeneratedMain.zig:29)
Caused by: java.util.ServiceConfigurationError: org.eclipse.microprofile.config.spi.ConfigSource: Provider org.jboss.resteasy.microprofile.config.ServletConfigSource could not be instantiated
    at java.util.ServiceLoader.fail(ServiceLoader.java:581)
    at java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:803)
    at java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:721)
    at java.util.ServiceLoader$3.next(ServiceLoader.java:1394)
    at java.lang.Iterable.forEach(Iterable.java:74)
    at io.smallrye.config.SmallRyeConfigBuilder.discoverSources(SmallRyeConfigBuilder.java:74)
    at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:175)
    at io.quarkus.runtime.generated.Config.readConfig(Config.zig:32805)
    at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(RuntimeConfigSetup.zig:38)
    at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:94)
    ... 6 more
Caused by: java.lang.RuntimeException: java.lang.InstantiationException: Type `org.jboss.resteasy.microprofile.config.ServletConfigSourceImpl` 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 org.jboss.resteasy.microprofile.config.BaseServletConfigSource.<init>(BaseServletConfigSource.java:26)
    at org.jboss.resteasy.microprofile.config.ServletConfigSource.<init>(ServletConfigSource.java:21)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:490)
    at java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:779)
    ... 14 more
Caused by: java.lang.InstantiationException: Type `org.jboss.resteasy.microprofile.config.ServletConfigSourceImpl` 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 org.jboss.resteasy.microprofile.config.BaseServletConfigSource.<init>(BaseServletConfigSource.java:23)
    ... 17 more

To Reproduce Sample project here: https://github.com/radcortez/microprofile-samples

  1. Build project with mvn verify
  2. Move to the folder services\number-api.
  3. Run mvn verify -Pnative
  4. Run ./target/number-api-runner

Configuration

# Add your application.properties here, if applicable.
quarkus.http.port=8081

# Logging
quarkus.log.console.enable=true
quarkus.log.console.format=%d{yyyy-MM-dd HH:mm:ss} %-5p [%c{3.}]] (%t) %s%e%n
quarkus.log.console.level=DEBUG
quarkus.log.console.color=true

# Tracking
quarkus.jaeger.service-name=number-api
quarkus.jaeger.sampler-type=const
quarkus.jaeger.sampler-param=1
quarkus.jaeger.propagation=b3

quarkus.swagger-ui.always-include=true

Environment (please complete the following information):

Additional context If we remove the dependency for quarkus-smallrye-opentracing, project runs fine in native. If we remove the registration of the custom Config Source in org.eclipse.microprofile.config.spi.ConfigSource it also works. Both together fail with the exception detailed above.


https://github.com/quarkusio/quarkus/issues/9086


$upstream:9086$