question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Environment property is not used in ContainerRequestFilter

See original GitHub issue

Describe the bug I want to use a Configuration Property in my Request Interceptor but when i try to overwrite it with an environmental variable it still uses the one from the application.properties. This behavior only appears when i am running it as a native image.

In this repository you can find the code. https://github.com/niedch/quarkus-env-property

Running in dev mode (mvn compile quarkus:dev) test.property in Interceptor: Injected from environment

Running in container using native-image test.property in Interceptor: Injected from application.properties (even if TEST_PROPERTY is present) One more thing is that everything is fine when using this Configproperty in the RestController Class

Expected Even if application is running as native image property should be injected from env

Actual behavior application is using the property from application.properties

To Reproduce Steps to reproduce the behavior:

  1. checkout repository
  2. mvn package -Pnative -Dquarkus.native.container-build=true
  3. docker build -t envinjection -f src/main/docker/Dockerfile.native .
  4. docker run -p 8081:8081 --env TEST_PROPERTY=test-from-env envinjection

Environment (please complete the following information):

  • uname: 18.04.1-Ubuntu
  • Output of java -version:
OpenJDK Runtime Environment (build 1.8.0_232-20191008104205.buildslave.jdk8u-src-tar--b07)
OpenJDK 64-Bit GraalVM CE 19.2.1 (build 25.232-b07-jvmci-19.2-b03, mixed mode)
  • GraalVM version (if different from Java): GraalVM Version 19.2.1 CE
  • Quarkus version or git rev: 0.28.1

Additional context Logs from application: mvn compile quarkus:dev

2019-11-08 11:38:16,395 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1) test property: test-from-env
2019-11-08 11:38:16,395 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1) interceptor:
2019-11-08 11:38:16,396 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1) SysPropConfigSource
2019-11-08 11:38:16,400 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1) EnvConfigSource
2019-11-08 11:38:16,402 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1)    TEST_PROPERTY : test-from-env
2019-11-08 11:38:16,412 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1) PropertiesConfigSource[source=application.properties]
2019-11-08 11:38:16,413 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1) PropertiesConfigSource[source=application.properties]
2019-11-08 11:38:16,414 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1)    test.property : test-property in application.properties
2019-11-08 11:38:16,415 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1) PropertiesConfigSource[source=application.properties]
2019-11-08 11:38:16,415 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1)    test.property : test-property in application.properties
2019-11-08 11:38:16,415 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1) PropertiesConfigSource[source=Build system]
2019-11-08 11:38:16,416 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1) null:null:ServletConfigSource
2019-11-08 11:38:16,416 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1) null:null:FilterConfigSource
2019-11-08 11:38:16,416 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1) null:ServletContextConfigSource
2019-11-08 11:38:16,416 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-1) default values
2019-11-08 11:38:16,418 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1) test property: test-from-env
2019-11-08 11:38:16,418 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1) endpoint:
2019-11-08 11:38:16,418 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1) SysPropConfigSource
2019-11-08 11:38:16,419 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1) EnvConfigSource
2019-11-08 11:38:16,420 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1)        TEST_PROPERTY : test-from-env
2019-11-08 11:38:16,426 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1) PropertiesConfigSource[source=application.properties]
2019-11-08 11:38:16,426 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1) PropertiesConfigSource[source=application.properties]
2019-11-08 11:38:16,426 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1)        test.property : test-property in application.properties
2019-11-08 11:38:16,426 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1) PropertiesConfigSource[source=application.properties]
2019-11-08 11:38:16,427 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1)        test.property : test-property in application.properties
2019-11-08 11:38:16,427 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1) PropertiesConfigSource[source=Build system]
2019-11-08 11:38:16,427 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1) null:null:ServletConfigSource
2019-11-08 11:38:16,427 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1) null:null:FilterConfigSource
2019-11-08 11:38:16,427 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1) null:ServletContextConfigSource
2019-11-08 11:38:16,427 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-1) default values

docker run -p 8081:8081 --env TEST_PROPERTY=test-from-env envinjection

2019-11-08 10:43:57,947 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-0) test property: test-property in application.properties
2019-11-08 10:43:57,947 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-0) interceptor:
2019-11-08 10:43:57,947 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-0) SysPropConfigSource
2019-11-08 10:43:57,947 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-0) EnvConfigSource
2019-11-08 10:43:57,947 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-0)    TEST_PROPERTY : test-from-env
2019-11-08 10:43:57,947 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-0) PropertiesConfigSource[source=application.properties]
2019-11-08 10:43:57,947 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-0) PropertiesConfigSource[source=application.properties]
2019-11-08 10:43:57,947 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-0) PropertiesConfigSource[source=Default configuration values]
2019-11-08 10:43:57,947 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-0)    test.property : test-from-env
2019-11-08 10:43:57,947 INFO  [tes.hom.Interceptor] (vert.x-worker-thread-0) default values
2019-11-08 10:43:57,947 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-0) test property: test-from-env
2019-11-08 10:43:57,947 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-0) endpoint:
2019-11-08 10:43:57,947 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-0) SysPropConfigSource
2019-11-08 10:43:57,948 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-0) EnvConfigSource
2019-11-08 10:43:57,948 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-0)        TEST_PROPERTY : test-from-env
2019-11-08 10:43:57,948 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-0) PropertiesConfigSource[source=application.properties]
2019-11-08 10:43:57,948 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-0) PropertiesConfigSource[source=application.properties]
2019-11-08 10:43:57,948 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-0) PropertiesConfigSource[source=Default configuration values]
2019-11-08 10:43:57,948 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-0)        test.property : test-from-env
2019-11-08 10:43:57,948 INFO  [tes.hom.ExampleResource] (vert.x-worker-thread-0) default values

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
gastaldicommented, Nov 8, 2019

I can confirm that it works if you add the following to the interceptor:

    @ConfigProperty(name = "test.property")
    javax.enterprise.inject.Instance<String> testProperty;

And then read the result using testProperty.get()

0reactions
geoandcommented, Jan 11, 2022

I am going to close this as this is not a problem in RESTEasy Reactive

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jersey ContainerRequestFilter not triggered - Stack Overflow
Okay, I didn't get that the jersey.config.server.provider.packages init param needs to reference not only service classes (API endpoints) but ALL the ...
Read more >
Security Tips and Tricks - Quarkus
If you are not using SSL, then you can selectively register security providers by name using the quarkus.security.security-providers property.
Read more >
Coding Filters and Interceptors for your RESTFul services
Filters are used to modify or process incoming and outgoing ... Header before the actual method invocation using a ContainerRequestFilter:
Read more >
Home of Quarkus Cheat-Sheet - GitHub Pages
Use Quarkus.waitForExit() from the main thread if you want to run some logic on startup, and then run like a normal application (i.e....
Read more >
RESTEasy JAX-RS - JBoss.org
This property is deprecated; please use a Servlet 3.0 container or higher and the ResteasyServletInitializer instead. resteasy.providers, no default, A comma ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found