Quarkus: Custom ConfigSource not working in quarkus:dev mode

Created on 26 Sep 2019  路  5Comments  路  Source: quarkusio/quarkus

I have a CustomSource that is working when run with the built jar, but does not work when run with mvnw compile quarkus:dev.

The CustomSource is a simple Property File Loader that is run at ordinal level 500, it reads the application.properties file the Working Directory.

Expected behavior
The internal application.properties has the quarkus.http.port set to 9090 and the external application.properties file has the quarkus.http.port set to 9292.

When I start up the application either through
mvnw compile quarkus:dev

or
java -jar target/quarkus-example-runner.jar

I am expecting it to listening on 9292.

Actual behavior
When started with the mvnw compile quarkus:dev it listens on 9090 and java -jar target/quarkus-example-runner.jar listens on 9292.

To Reproduce
Steps to reproduce the behavior:

  1. Build with a maven clean package goals
  2. ./mvnw compile quarkus:dev
  3. java -jar target/quarkus-example-runner.jar

Configuration

# Add your application.properties here, if applicable.

Included in the zip.
QuarkusExample.zip

Screenshots
(If applicable, add screenshots to help explain your problem.)
Screen Shot 2019-09-26 at 11 56 47

Environment (please complete the following information):

  • Output of uname -a or ver: Darwin brentsmcbookpro.xxxxxl 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64
  • Output of java -version: 1.8.0_222, x86_64: "AdoptOpenJDK 8"
  • GraalVM version (if different from Java): Not compile native as yet
  • Quarkus version or git rev: 0.22.0

Additional context
(Add any other context about the problem here.)

triaginvalid

Most helpful comment

No problem will do.

All 5 comments

@brentcrammond that's because when you do the following while running mvn compile quarkus:dev:

        try (InputStream is = new FileInputStream("application.properties")) {

you are actually reading the application.properties from src/main/resources (because the user.dir is set to the target/classes/ directory). Try replacing with an absolute path and you'll see that your ConfigSource is correctly called.

You can also run ./mvnw compile quarkus:dev -Ddebug and configure your IDE to remote debug your project in port 5005 to confirm that's true

I am going to go ahead and close as per the explanation from @gastaldi . If you think it should be reopened, feel free to do so adding more information.

Thanks

Thanks I understand the problem now.

I am quite surprised that the working directory is changed when the application is run through "mvnw compile quarkus:dev" and would suggest that it should be running as one would expect in the directory that you start the mvnw in.

I suspect there are good reason for it to be run with the working directory being in target/classes, but this is not the behaviour I would have expected.

Could I suggest this be changed to an enhancement to change the behaviour of the "mvnw compile quarkus:dev" to work in a more intuitive fashion. This will be confusing to people new to the Quarkus framework.

Basically it comes down to when I run something from a directory I expect it to be running in that directory rather than changing to another directory.

Interesting suggestion! Do you mind copying it to a new issue?

Thanks!

No problem will do.

Was this page helpful?
0 / 5 - 0 ratings