quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.58k stars 2.63k forks source link

Configuring application using YAML doesn't work as expected #6296

Closed x80486 closed 4 years ago

x80486 commented 4 years ago

Describe the bug

I have a small Quarkus 1.1.0 (Web) application. It's working fine if I start it with my current application.properties, but as soon as I try to "migrate" it to YAML it stops working.

Mandatory StackOverflow question.

Expected behavior

The application should work as before.

Actual behavior

After putting this dependency: io.quarkus:quarkus-config-yaml, placing application.yaml under src/main/resources/, and deleting the actual application.properties (in the same location), I get these error messages:

14:17:21,950 ERROR [io.qua.dev.DevModeMain] Failed to start Quarkus: java.lang.RuntimeException: io.quarkus.builder.ChainBuildException: No producers for required item class io.quarkus.deployment.builditem.BuildTimeRunTimeFixedConfigurationBuildItem
    at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:180)
    at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:177)
    at io.quarkus.dev.DevModeMain.start(DevModeMain.java:95)
    at io.quarkus.dev.DevModeMain.main(DevModeMain.java:66)
Caused by: io.quarkus.builder.ChainBuildException: No producers for required item class io.quarkus.deployment.builditem.BuildTimeRunTimeFixedConfigurationBuildItem
    at io.quarkus.builder.BuildChainBuilder.build(BuildChainBuilder.java:240)
    at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:112)
    at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:113)
    ... 3 more

14:17:21,973 INFO  [io.qua.dev.DevModeMain] Attempting to start hot replacement endpoint to recover from previous Quarkus startup failure
14:17:21,987 ERROR [io.qua.dev.DevModeMain] Failed to start quarkus: java.lang.IllegalArgumentException: workerPoolSize must be > 0
    at io.vertx.core.VertxOptions.setWorkerPoolSize(VertxOptions.java:275)
    at io.quarkus.vertx.core.runtime.VertxCoreRecorder.convertToVertxOptions(VertxCoreRecorder.java:151)
    at io.quarkus.vertx.core.runtime.VertxCoreRecorder.initializeWeb(VertxCoreRecorder.java:104)
    at io.quarkus.vertx.http.runtime.VertxHttpRecorder.startServerAfterFailedStart(VertxHttpRecorder.java:115)
    at io.quarkus.vertx.http.deployment.devmode.VertxHotReplacementSetup.handleFailedInitialStart(VertxHotReplacementSetup.java:30)
    at io.quarkus.dev.RuntimeUpdatesProcessor.startupFailed(RuntimeUpdatesProcessor.java:449)
    at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:191)
    at io.quarkus.dev.DevModeMain.start(DevModeMain.java:95)
    at io.quarkus.dev.DevModeMain.main(DevModeMain.java:66)

> Task :quarkusDev FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':quarkusDev'.
> Build cancelled while executing task ':quarkusDev'

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 48s

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
4 actionable tasks: 3 executed, 1 up-to-date
2:17:32 PM: Tasks execution finished 'clean quarkusDev'.

To Reproduce

  1. Create a brand new Gradle project (using version 6.0.1)
  2. Use these Gradle scripts and the gradle.properties:
#
# Dependency Versions
quarkus.version = 1.1.0.Final

#
# Gradle Settings
org.gradle.configureondemand = false
org.gradle.daemon = false
# settings.gradle
pluginManagement {
  plugins {
    id "eclipse"
    id "idea"
    id "io.quarkus" version "${getProperty("quarkus.version")}"
    id "java"
  }
}

rootProject.name = "java-quarkus-web"
# build.gradle
import io.quarkus.gradle.tasks.QuarkusNative
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent

import java.nio.charset.StandardCharsets
import java.time.ZoneOffset
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter

buildscript { // ...still necessary to make enforcedPlatform work for Quarkus plugin
  dependencies {
    classpath "io.quarkus:quarkus-gradle-plugin:${project.property("quarkus.version")}"
  }

  repositories {
    jcenter()
    mavenCentral()
  }
}

plugins {
  id "eclipse"
  id "idea"
  // id "io.quarkus" // TODO: Adding plugin in legacy format >:(
  id "java"
}

// apply from: "another.gradle"
// apply plugin: "tld.plugin-name"
apply plugin: "io.quarkus"

group = "org.acme"
description = "Container-based Quarkus Web Application"

configurations {
  // all*.exclude module: "dependency-identifier"
}

repositories {
  // mavenLocal() // Uncomment when needed
  jcenter()
  mavenCentral()
}

dependencies {
  //-----------------------------------------------------------------------------------------------
  //  Experimental Dependencies
  //-----------------------------------------------------------------------------------------------

  //-----------------------------------------------------------------------------------------------
  //  BOM Support
  //-----------------------------------------------------------------------------------------------

  implementation enforcedPlatform("io.quarkus:quarkus-bom:${project.property("quarkus.version")}")

  //-----------------------------------------------------------------------------------------------
  //  Project Dependencies
  //-----------------------------------------------------------------------------------------------

  implementation "io.quarkus:quarkus-config-yaml"
  implementation "io.quarkus:quarkus-flyway"
  implementation "io.quarkus:quarkus-hibernate-orm-panache"
  implementation "io.quarkus:quarkus-jdbc-postgresql"
  implementation "io.quarkus:quarkus-resteasy-jackson"
  implementation "io.quarkus:quarkus-resteasy"
  implementation "io.quarkus:quarkus-smallrye-fault-tolerance"
  implementation "io.quarkus:quarkus-smallrye-health"
  implementation "io.quarkus:quarkus-smallrye-metrics"
  implementation "io.quarkus:quarkus-smallrye-openapi"
  implementation "org.apache.commons:commons-lang3:3.9"

  //-----------------------------------------------------------------------------------------------
  //  Test Dependencies
  //-----------------------------------------------------------------------------------------------

  testImplementation "io.quarkus:quarkus-junit5"
  testImplementation "io.rest-assured:rest-assured"
  testImplementation "org.assertj:assertj-core"
  testImplementation "org.springframework:spring-test:5.1.2.RELEASE" // TODO: Quarkus folks need ReflectionTestUtils in io.quarkus:quarkus-junit5 !!!
}

//=================================================================================================
//  P L U G I N S
//=================================================================================================

java {
  sourceCompatibility = JavaVersion.VERSION_1_8
  targetCompatibility = JavaVersion.VERSION_1_8
}

quarkus {
  // ...
}

//=================================================================================================
//  T A S K S
//=================================================================================================

tasks.withType(Jar) {
  final def attrs = [
    "Application-Name": project.name,
    "Build-Date": ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ISO_DATE_TIME),
    // "Build-Number": ,
    "Created-By": System.getProperty("user.name"),
    "Gradle-Version": gradle.gradleVersion,
    "Implementation-Title": project.name,
    "Implementation-Vendor": "Acme Corp.",
    "Implementation-Version": project.version, // ...should be the build number
    "JDK-Version": System.getProperty("java.version"),
    "Specification-Title": project.name,
    "Specification-Vendor": "Acme Corp.",
    "Specification-Version": project.version,
  ]
  exclude(".gitkeep")
  manifest { attributes(attrs) }
}

tasks.withType(JavaCompile) {
  options.compilerArgs << "-parameters"
  options.encoding = "${StandardCharsets.UTF_8}"
}

tasks.withType(QuarkusNative) {
  additionalBuildArgs = [
    // "-H:ReflectionConfigurationFiles=reflection-config.json",
    // "-H:ResourceConfigurationFiles=resources-config.json",
  ]
}

tasks.withType(Test) {
  // exclude("**/Native*")
  systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
  testLogging {
    events = [TestLogEvent.FAILED, TestLogEvent.SKIPPED]
    exceptionFormat = TestExceptionFormat.FULL
    showCauses = true
    showExceptions = true
    showStackTraces = true
  }
  useJUnitPlatform()
}
  1. Run the project

Configuration

quarkus:
  datasource:
    driver: org.postgresql.Driver
  flyway:
    migrate-at-start: true
  health:
    extensions:
      enabled: true
  hibernate-orm:
    dialect: org.hibernate.dialect.PostgreSQL10Dialect
  http:
    port: 8080
  log: # ALL > FINEST > FINER > FINE > CONFIG > INFO > WARNING > SEVERE > OFF
    console:
      async: true
      color: true
      enable: true
      format: "%d{yyyy-MM-dd HH:mm:ss,SSS} |- %-5p in %c:%L{3.} [%t] - %s%e%n"
    level: WARNING
  resteasy:
    path: /api
  smallrye-openapi:
    path: /open-api
  swagger-ui:
    always-include: true
    path: /swagger-ui
"%dev":
  quarkus:
    datasource:
      password: postgres
      url: jdbc:postgresql://localhost:5432/quarkus_web
      username: postgres
    flyway:
      clean-at-start: true
    hibernate-orm:
      log:
        sql: true
      statistics: true
    log:
      category:
        "io.quarkus.arc.processor":
          level: OFF
        "io.quarkus":
          level: INFO
        "org.acme":
          level: CONFIG
"%prod":
  quarkus:
    datasource:
      password: postgres
      url: jdbc:postgresql://localhost:5432/quarkus_web
      username: postgres
    flyway:
      clean-at-start: false
    hibernate-orm:
      database:
        generation: none
      sql-load-script: no-file
"%test":
  quarkus:
    datasource:
      password: postgres
      url: jdbc:postgresql://localhost:5432/quarkus_web
      username: postgres
    flyway:
      clean-at-start: true
    log:
      category:
        "io.quarkus":
          level: WARNING
        "org.acme":
          level: WARNING

Environment

Please complete the following information):

x80486 commented 4 years ago

Mmmm...while I still chasing this, I deleted the entire Gradle cache (and what not); now I'm getting this:

[x80486@uplink java-quarkus-web]$ ./gradlew clean quarkusDev
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/6.0.1/userguide/gradle_daemon.html.
Daemon will be stopped at the end of the build stopping after processing

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'java-quarkus-web'.
> Could not resolve all artifacts for configuration ':classpath'.
   > Could not find io.quarkus:quarkus-gradle-plugin:1.1.0.Final.
     Searched in the following locations:
       - https://jcenter.bintray.com/io/quarkus/quarkus-gradle-plugin/1.1.0.Final/quarkus-gradle-plugin-1.1.0.Final.pom
       - https://repo.maven.apache.org/maven2/io/quarkus/quarkus-gradle-plugin/1.1.0.Final/quarkus-gradle-plugin-1.1.0.Final.pom
       - https://plugins.gradle.org/m2/io/quarkus/quarkus-gradle-plugin/1.1.0.Final/quarkus-gradle-plugin-1.1.0.Final.pom
     Required by:
         project :

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 15s

I have the feeling that this was caused because when I upgraded, it was still using the plugin version 1.0.1.Final. Right now I can't even get to the plugin version 1.1.0.Final, so probably this is not an issue 🙄

gsmet commented 4 years ago

The Gradle support has changed a bit in 1.1.0.Final: https://github.com/quarkusio/quarkus/wiki/Migration-Guide#gradle-plugin .

We will announce 1.1.0.Final with all the pointers on Monday.

x80486 commented 4 years ago

OK, you can ignore this one...it's not an issue. I followed the "new" migration guide for Gradle and it works as expected.

I was waiting for that change! I didn't think it would arrive that soon! 🎉

gsmet commented 4 years ago

Cool, thanks for the feedback!