quarkusio / quarkus

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

gradle quarkusBuild has error : SRCFG00035: Failed to load resource #16429

Closed ixre closed 3 years ago

ixre commented 3 years ago

Since upgrading from to 1.13.x, run below command

./gradlew  quarkusBuild -Dquarkus.package.type=uber-jar  -Dorg.gradle.jvmargs=-Xmx256m

Gradle made a error: SRCFG00035: Failed to load resource, full stacktrace is:

> Task :processResources

> Task :classes
start copy some files...

> Task :inspectClassesForKotlinIC
> Task :jar

> Task :quarkusBuild
building quarkus jar

> Task :quarkusBuild FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':quarkusBuild'.
> java.lang.IllegalStateException: SRCFG00035: Failed to load resource

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

My system jdk version :

openjdk 11.0.10 2021-01-19
OpenJDK Runtime Environment 18.9 (build 11.0.10+9)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.10+9, mixed mode, sharing)

when I use adoptjdk15-openj9 or downgrade quarkus version to 1.12.2.Final, it' all fine.

quarkus-bot[bot] commented 3 years ago

/cc @evanchooly, @glefloch, @quarkusio/devtools

glefloch commented 3 years ago

@ixre, I just tested with a simple project generated from code.quarkus.io and the build was successful with your command, Can you share a reproducer and also the full stacktrace of the gradle output ? (you can get it with -S flag on the gradle command)

rpr13 commented 3 years ago

I have same error code.

gradle clean build --debug --stacktrace

2021-04-16T07:32:05.732+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.smallrye.config.AbstractLocationConfigSourceLoader.tryFileSystem(AbstractLocationConfigSourceLoader.java:100)
2021-04-16T07:32:05.742+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.smallrye.config.AbstractLocationConfigSourceLoader.loadConfigSources(AbstractLocationConfigSourceLoader.java:81)
2021-04-16T07:32:05.742+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.smallrye.config.AbstractLocationConfigSourceLoader.loadConfigSources(AbstractLocationConfigSourceLoader.java:65)
2021-04-16T07:32:05.742+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.smallrye.config.DotEnvConfigSourceProvider.getConfigSources(DotEnvConfigSourceProvider.java:45)
2021-04-16T07:32:05.742+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.quarkus.runtime.configuration.ConfigUtils.configBuilder(ConfigUtils.java:108)
2021-04-16T07:32:05.742+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.quarkus.runtime.configuration.ConfigUtils.configBuilder(ConfigUtils.java:67)
2021-04-16T07:32:05.742+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.quarkus.deployment.ExtensionLoader.loadStepsFrom(ExtensionLoader.java:146)
2021-04-16T07:32:05.742+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:101)
2021-04-16T07:32:05.742+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:394)
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 124 more
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.nio.file.NoSuchFileException: /home/rpr/.gradle/daemon/7.0/.env
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.smallrye.common.classloader.ClassPathUtils.readStream(ClassPathUtils.java:205)
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.smallrye.common.classloader.ClassPathUtils.consumeStream(ClassPathUtils.java:158)
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.smallrye.config.common.utils.ConfigSourceUtil.urlToMap(ConfigSourceUtil.java:64)
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.quarkus.runtime.configuration.ConfigUtils$BuildTimeDotEnvConfigSourceProvider.loadConfigSource(ConfigUtils.java:202)
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.smallrye.config.DotEnvConfigSourceProvider.loadConfigSource(DotEnvConfigSourceProvider.java:30)
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at io.smallrye.config.AbstractLocationConfigSourceLoader.addConfigSource(AbstractLocationConfigSourceLoader.java:206)
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 140 more
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Get more help at https://help.gradle.org
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] 
2021-04-16T07:32:05.743+0200 [ERROR] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED in 16s

I needed to add symlink from project to /home/rpr/.gradle/daemon/7.0/.env

glefloch commented 3 years ago

@rpr13 have you a reproducer? it looks like you are using gradle 7.0, have the same issue with gradle 6.8.3 ?

rpr13 commented 3 years ago

Hi, I don't know what reproducer is.

Same thing happened on gradle 6.8.3.

glefloch commented 3 years ago

just a sample project that fails with this error.

rpr13 commented 3 years ago

I have this build.gradle.kts

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

group = "test"
version = "1.0.0"

plugins {
    kotlin("jvm") version "1.4.32"
    id("io.quarkus") version "1.13.2.Final"
}

repositories {
    mavenCentral()
}

val coroutinesVersion = "1.4.3"
val quarkusPlatformVersion = "1.13.2.Final"
val influxDbClientJavaVersion = "2.1.0"
val influxDbJavaVersion = "2.21"
val sshdVersion = "2.6.0"
val joolVersion = "0.9.14"

dependencies {
    implementation(platform(kotlin("bom")))
    implementation(kotlin("reflect"))
    implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")

//  implementation(platform("io.quarkus:quarkus-bom:${quarkusPlatformVersion}"))
    implementation(platform("io.quarkus:quarkus-universe-bom:${quarkusPlatformVersion}"))
    implementation("io.quarkus:quarkus-kotlin")
    implementation("io.quarkus:quarkus-resteasy-jsonb")
    implementation("io.quarkus:quarkus-hibernate-orm-panache-kotlin")
    implementation("io.quarkus:quarkus-jdbc-mariadb")
    implementation("io.quarkus:quarkus-jdbc-mysql")
    implementation("io.quarkus:quarkus-smallrye-openapi")
    implementation("io.quarkus:quarkus-oidc")
    implementation("io.quarkus:quarkus-scheduler")
    implementation("io.quarkus:quarkus-quartz")

    implementation("com.influxdb:influxdb-client-java:${influxDbClientJavaVersion}")
    implementation("org.influxdb:influxdb-java:${influxDbJavaVersion}")
    implementation("org.apache.sshd:sshd-core:${sshdVersion}")
    implementation("org.amqphub.quarkus:quarkus-qpid-jms")

    // https://github.com/jOOQ/jOOL
    implementation("org.jooq:jool:${joolVersion}")

    testImplementation("io.quarkus:quarkus-junit5")
    testImplementation("io.rest-assured:rest-assured")
    testImplementation("io.rest-assured:kotlin-extensions")
}

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

tasks.withType<JavaCompile> {
    options.encoding = "UTF-8"
    options.compilerArgs.add("-parameters")
}

tasks.withType<KotlinCompile>().configureEach {
    kotlinOptions.jvmTarget = "11"
}

tasks.wrapper { distributionType = Wrapper.DistributionType.ALL }
rpr13 commented 3 years ago

Oh And example .env file

TEST=test
glefloch commented 3 years ago

Thanks I will test with that.

gerritdrost commented 3 years ago

Experiencing similar problems as described in https://github.com/quarkusio/quarkus/issues/16429#issuecomment-820922132, but with config/application.properties instead of .env:

$ ./gradlew clean build
...
Caused by: java.nio.file.NoSuchFileException: /home/gerrit/.gradle/daemon/6.8.3/config/application.properties
...
x80486 commented 3 years ago

Issue was introduced from 1.13.0.Final until the actual version:

[x80486@uplink:~/somewhere/kotlin-quarkus]$ ./gradlew -Dquarkus.package.type=fast-jar --stacktrace clean quarkusBuild 
...
Caused by: java.lang.IllegalStateException: SRCFG00035: Failed to load resource
        at io.smallrye.config.AbstractLocationConfigSourceLoader.addConfigSource(AbstractLocationConfigSourceLoader.java:209)
        at io.smallrye.config.AbstractLocationConfigSourceLoader.addConfigSource(AbstractLocationConfigSourceLoader.java:201)
        at io.smallrye.config.AbstractLocationConfigSourceLoader.access$300(AbstractLocationConfigSourceLoader.java:49)
        at io.smallrye.config.AbstractLocationConfigSourceLoader$ConfigSourcePathConsumer.accept(AbstractLocationConfigSourceLoader.java:290)
        at io.smallrye.config.AbstractLocationConfigSourceLoader$ConfigSourcePathConsumer.accept(AbstractLocationConfigSourceLoader.java:279)
        at io.smallrye.common.classloader.ClassPathUtils.lambda$consumeAsPath$0(ClassPathUtils.java:102)
        at io.smallrye.common.classloader.ClassPathUtils.processAsPath(ClassPathUtils.java:140)
        at io.smallrye.common.classloader.ClassPathUtils.consumeAsPath(ClassPathUtils.java:101)
        at io.smallrye.config.AbstractLocationConfigSourceLoader.tryFileSystem(AbstractLocationConfigSourceLoader.java:100)
        at io.smallrye.config.AbstractLocationConfigSourceLoader.loadConfigSources(AbstractLocationConfigSourceLoader.java:81)
        at io.smallrye.config.AbstractLocationConfigSourceLoader.loadConfigSources(AbstractLocationConfigSourceLoader.java:65)
        at io.smallrye.config.DotEnvConfigSourceProvider.getConfigSources(DotEnvConfigSourceProvider.java:45)
        at io.quarkus.runtime.configuration.ConfigUtils.configBuilder(ConfigUtils.java:105)
        at io.quarkus.runtime.configuration.ConfigUtils.configBuilder(ConfigUtils.java:64)
        at io.quarkus.deployment.ExtensionLoader.loadStepsFrom(ExtensionLoader.java:146)
        at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:101)
        at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:394)
        ... 124 more
Caused by: java.nio.file.NoSuchFileException: /home/x80486/.gradle/daemon/7.0/.env
        at io.smallrye.common.classloader.ClassPathUtils.readStream(ClassPathUtils.java:205)
        at io.smallrye.common.classloader.ClassPathUtils.consumeStream(ClassPathUtils.java:158)
        at io.smallrye.config.common.utils.ConfigSourceUtil.urlToMap(ConfigSourceUtil.java:64)
        at io.quarkus.runtime.configuration.ConfigUtils$BuildTimeDotEnvConfigSourceProvider.loadConfigSource(ConfigUtils.java:181)
        at io.smallrye.config.DotEnvConfigSourceProvider.loadConfigSource(DotEnvConfigSourceProvider.java:30)
        at io.smallrye.config.AbstractLocationConfigSourceLoader.addConfigSource(AbstractLocationConfigSourceLoader.java:206)
        ... 140 more

I tested all those versions one by one 😅 ...1.12.2.Final is fine.

glefloch commented 3 years ago

@radcortez have you already seen this? I don't why it tries to load a .env from gradle home ..

radcortez commented 3 years ago

Hum, the files are optional. So this shouldn't happen. Let me have a look.

gerritdrost commented 3 years ago

To clarify, in my case I have a config/application.properties in my project directory. It seems like it detects the file correctly from the project directory, but then uses the wrong working directory when trying to read it.

When I delete config/application.properties in the project directory, the build succeeds.

radcortez commented 3 years ago

Hum, it seems this is caused by the Gradle Daemon setting the default directory and later in the execution modifying the user.dir to the right directory, but the Filesystem default directory still keeps the original daemon directory.

When we introduced the new config loader, we call url.toUri() which resolves to the daemon path (the initial default) and not the updated user.dir. The default is cached in java.nio.file.FileSystems.

radcortez commented 3 years ago

I think we may be able to fix this if we construct a valid URI with the user.dir at the source level instead of relying in the relative path. BTW, Maven seems to work fine.

radcortez commented 3 years ago

Hopefully #16777 will fix this.

brianmcgee commented 3 years ago

Any suggestions how to workaround this in the meantime? I have a build that has just started throwing this despite not changing anything.

radcortez commented 3 years ago

Hi @brianmcgee,

Which Quarkus version are you using? Did you update between not observing the issue and when experiencing the issue? Do you have an application.properties in the config folder?

brianmcgee commented 3 years ago

@radcortez I'm using 1.13.2.Final. I haven't changed the version and I'm using an application.yaml in the src/main/resources directory, no config folder

brianmcgee commented 3 years ago

I was able to resolve my issue. Here's what happened.

I have a multi module project and one of the sub modules was failing to build. I had added a .env file in the root directory for docker-compose and it seems from the stack trace that is what it was incorrectly picking up as being in the gradle root directory . Removing it fixed the problem.

In this instance I can work around having the .env file

radcortez commented 3 years ago

Are you able to try this out with 1.13.4.Final. It should be fixed in that version.

This was fixed in https://github.com/quarkusio/quarkus/issues/16429, but apparently the automatic link pull request failed.

baivoom commented 2 years ago

Hi @radcortez , same issue here while executing Quarkusbuild

Quarkus 2.7.5.Final Gradle 7.4.1 IDE : IntelliJ CE

Error: /Users/developer/.gradle/daemon/7.4.1/config/application.yml

at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:104)
    at io.quarkus.runner.bootstrap.AugmentActionImpl.runAugment(AugmentActionImpl.java:328)
    ... 121 more
Caused by: java.nio.file.NoSuchFileException: /Users/developer/.gradle/daemon/7.4.1/config/application.yml
    at io.smallrye.common.classloader.ClassPathUtils.readStream(ClassPathUtils.java:196)
    at io.smallrye.config.source.yaml.YamlConfigSource.<init>(YamlConfigSource.java:68)
    at io.quarkus.config.yaml.runtime.ApplicationYamlConfigSourceLoader.loadConfigSource(ApplicationYamlConfigSourceLoader.java:26)
    at io.smallrye.config.AbstractLocationConfigSourceLoader.addConfigSource(AbstractLocationConfigSourceLoader.java:217)
    ... 141 more

Current code

 public static class InClassPath extends ApplicationYamlConfigSourceLoader implements ConfigSourceProvider {
        @Override
        public List<ConfigSource> getConfigSources(final ClassLoader classLoader) {
            List<ConfigSource> configSources = new ArrayList<>();
            configSources.addAll(loadConfigSources("application.yaml", 255, classLoader));
            configSources.addAll(loadConfigSources("application.yml", 255, classLoader));
            return configSources;
        }

        @Override
        protected List<ConfigSource> tryFileSystem(final URI uri, final int ordinal) {
            return new ArrayList<>();
        }
    }

    public static class InFileSystem extends ApplicationYamlConfigSourceLoader implements ConfigSourceProvider {
        @Override
        public List<ConfigSource> getConfigSources(final ClassLoader classLoader) {
            List<ConfigSource> configSources = new ArrayList<>();
            configSources.addAll(loadConfigSources("config/application.yaml", 265, classLoader));
            configSources.addAll(loadConfigSources("config/application.yml", 265, classLoader));
            return configSources;
        }

        @Override
        protected List<ConfigSource> tryClassPath(final URI uri, final int ordinal, final ClassLoader classLoader) {
            return new ArrayList<>();
        }
    }

Original fixed version,

@Override
        public List<ConfigSource> getConfigSources(final ClassLoader classLoader) {
            return loadConfigSources("config/application.properties", classLoader);
            return loadConfigSources(
                    Paths.get(System.getProperty("user.dir"), "config", "application.properties").toUri().toString(),
                    classLoader);
        }
radcortez commented 2 years ago

@baivoom can you please provide a reproducer? Thanks!

baivoom commented 2 years ago

Hi @radcortez here is the reproduce , I am using IntelliJ. I found the error is caused by a config/application.yml in the root of project, removing that file is a workaround, however that is not the final solution, IMO

quarkus-config-issue.zip

radcortez commented 2 years ago

@baivoom Thank. It seems the fix was missing for the YAML source. Interesting that no one noticed until now. I'm sorry for the inconvenience. There is a fix in https://github.com/quarkusio/quarkus/pull/24587.

jmini commented 1 year ago

I found a different but very similar issue: https://github.com/quarkusio/quarkus/issues/36767 (because of the presence of an empty application.properties file at the root of the project)