Quarkus: "DeploymentException: No config value of type [java.lang.String] exists for" in multi-module Gradle project

Created on 1 May 2020  路  26Comments  路  Source: quarkusio/quarkus

Describe the bug

I was wondering why I never was getting the ConfigProperties and ConfigProperty annotations working in my multi module project, now I found out that ConfigProperty fields cannot be loaded when the child/sub module has an application.properties file itself. It seems to collide or override the values of the application.properties file of the main application module.

Version

  • Quarkus 1.4.1.Final

Actual behavior

java.lang.RuntimeException: Failed to start quarkus
java.lang.RuntimeException: java.lang.RuntimeException: Failed to start quarkus
    at io.quarkus.test.junit.QuarkusTestExtension.beforeEach(QuarkusTestExtension.java:255)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$1(TestMethodTestDescriptor.java:161)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$5(TestMethodTestDescriptor.java:197)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:197)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:160)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:131)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1510)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1510)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220)
    at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188)
    at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:99)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:79)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:75)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:61)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at com.sun.proxy.$Proxy2.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.stop(TestWorker.java:132)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
    at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
    at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:412)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
    at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.RuntimeException: Failed to start quarkus
    at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:368)
    at io.quarkus.runtime.Application.start(Application.java:89)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at io.quarkus.runner.bootstrap.StartupActionImpl.run(StartupActionImpl.java:177)
    at io.quarkus.test.junit.QuarkusTestExtension.doJavaStart(QuarkusTestExtension.java:142)
    at io.quarkus.test.junit.QuarkusTestExtension.ensureStarted(QuarkusTestExtension.java:269)
    at io.quarkus.test.junit.QuarkusTestExtension.beforeAll(QuarkusTestExtension.java:292)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$invokeBeforeAllCallbacks$7(ClassBasedTestDescriptor.java:359)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeBeforeAllCallbacks(ClassBasedTestDescriptor.java:359)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:189)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.before(ClassBasedTestDescriptor.java:78)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:132)
    ... 54 more
Caused by: java.util.NoSuchElementException: Property scheduler.cron not found
    at io.smallrye.config.SmallRyeConfig.propertyNotFound(SmallRyeConfig.java:209)
    at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:96)
    at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:80)
    at io.quarkus.scheduler.runtime.SimpleScheduler.parseDuration(SimpleScheduler.java:187)
    at io.quarkus.scheduler.runtime.SimpleScheduler.createTrigger(SimpleScheduler.java:177)
    at io.quarkus.scheduler.runtime.SimpleScheduler.<init>(SimpleScheduler.java:77)
    at io.quarkus.scheduler.runtime.SimpleScheduler_Bean.create(SimpleScheduler_Bean.zig:302)
    at io.quarkus.scheduler.runtime.SimpleScheduler_Bean.create(SimpleScheduler_Bean.zig:317)
    at io.quarkus.arc.impl.AbstractSharedContext.createInstanceHandle(AbstractSharedContext.java:79)
    at io.quarkus.arc.impl.ComputingCache$CacheFunction.lambda$apply$0(ComputingCache.java:99)
    at io.quarkus.arc.impl.LazyValue.get(LazyValue.java:26)
    at io.quarkus.arc.impl.ComputingCache.getValue(ComputingCache.java:41)
    at io.quarkus.arc.impl.AbstractSharedContext.get(AbstractSharedContext.java:25)
    at io.quarkus.scheduler.runtime.SimpleScheduler_Observer_start_09e6c17011ef77dec3e1dd9987380b3d946e3db6.notify(SimpleScheduler_Observer_start_09e6c17011ef77dec3e1dd9987380b3d946e3db6.zig:147)
    at io.quarkus.arc.impl.EventImpl$Notifier.notifyObservers(EventImpl.java:282)
    at io.quarkus.arc.impl.EventImpl$Notifier.notify(EventImpl.java:267)
    at io.quarkus.arc.impl.EventImpl.fire(EventImpl.java:69)
    at io.quarkus.arc.runtime.LifecycleEventRunner.fireStartupEvent(LifecycleEventRunner.java:23)
    at io.quarkus.arc.runtime.ArcRecorder.handleLifecycleEvents(ArcRecorder.java:113)
    at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent64.deploy_0(LifecycleEventsBuildStep$startupEvent64.zig:77)
    at io.quarkus.deployment.steps.LifecycleEventsBuildStep$startupEvent64.deploy(LifecycleEventsBuildStep$startupEvent64.zig:36)
    at io.quarkus.runner.ApplicationImpl.doStart(ApplicationImpl.zig:299)
    ... 69 more

To Reproduce
Steps to reproduce the behavior:

I麓ve created a reproducer with different usages of the ConfigProperties. Run it as it is and it will fail. Comment out the child module in the application/build.gradle and tests will work.

Reproducer: https://github.com/mklueh/quarkus-multi-module-config-property-issue

What is the strategy with submodule application.properties in general, does this work in any hierarchical depth? Are they merged with the main module or should they be ignored?

In my case I don麓t need the submodule properties in my application, but my submodule has some tests itself which requires the properties file.

aregradle kinbug triaginvalid

All 26 comments

/cc @quarkusio/devtools

There could also be a relation to this issue https://github.com/quarkusio/quarkus/issues/8966

Would you be willing to build Quarkus from master and try?
There were some changes done (I am thinking of https://github.com/quarkusio/quarkus/pull/8930) that could potentially fix the issue.

@geoand I麓ll try that. What is the best way to proceed after building it? Using the local maven repository or do I have to copy jar files around? What happens with all the other Quarkus dependencies?

Once you build Quarkus from master all Quarkus dependencies should be built into your local maven repository.
Then simple use 999-SNAPSHOT as the quarkus version and quarkus-bom instead of quarkus-universe-bom.

This assumes you aren't using anything from the Quarkus platform (like Camel Quarkus).

Cool, thanks. I麓d assume this is the right config then?

quarkusPlatformArtifactId=quarkus-bom #quarkus-universe-bom
quarkusPluginVersion=999-SNAPSHOT #1.4.1.Final
quarkusPlatformVersion=1.4.1.Final

Best use quarkusPlatformVersion=999-SNAPSHOT as well

Alright. Maybe this should be part of the contribution guide?

That's a good idea!

Would you like to submit a Pull Request adding that information?

@geoand I would, but it麓s not working for me.

The Quarkus build was successful but I麓m running into this when running the tests after I麓ve dropped a lot of dependencies out of my project that weren麓t found as well

Could not find io.quarkus:quarkus-hibernate-orm-panache:.
Required by:
project :common-base
Could not find io.quarkus:quarkus-bom:999-SNAPSHOT.
Required by:
project :common-base

All of these imports are not found anymore now


import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;

import javax.inject.Inject;

import static org.junit.jupiter.api.Assertions.assertNotNull;

I麓ve also changed the order of the repositories and put mavenLocal on top

pluginManagement {
    repositories {
        mavenLocal()
        jcenter()
        mavenCentral()
        gradlePluginPortal()
    }
    //noinspection GroovyAssignabilityCheck
    plugins {
        id 'io.quarkus' version "${quarkusPluginVersion}"
    }
}

Am I missing something?

Here is what I am using in a test gradle project:

setting.gralde:

pluginManagement {
    repositories {
        mavenLocal()
        mavenCentral()
        gradlePluginPortal()
    }
    plugins {
      id 'io.quarkus' version "${quarkusPluginVersion}"
    }
}
rootProject.name='test-gradle'

build.gradle (not complete):

plugins {
    id 'java'
    id 'io.quarkus'
}

repositories {
     mavenLocal()
     mavenCentral()
}

dependencies {
    implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
....

}

....

gradle.properties:

quarkusPluginVersion=999-SNAPSHOT
quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformGroupId=io.quarkus
quarkusPlatformVersion=999-SNAPSHOT

Thanks, I was missing the mavenLocal() in the build.gradle and it麓s starting now, but the "No config value exists" issue is still there.

cc @aloubyansky

@aloubyansky we have a reproducer in the original description for this one.

This and #9137 could be related.

Your reproducers are great @mklueh, btw. Thanks a lot. I'm adding them to our testsuite.

Your reproducers are great @mklueh, btw. Thanks a lot. I'm adding them to our testsuite.

Thanks, nice to hear :)

@aloubyansky I found out that it is related to the application.properties file in the application/test/resources/ directory (which is also in the reproducer).

Removing that resolves this issue as well.

Could also be related to this post https://github.com/quarkusio/quarkus/issues/8966#issuecomment-622027248

Some very weird things are going on with the properties files

For tests, application.properties in test resources is expected to completely replace the main properties.

I'll get back to this issue soon. Are you saying the test properties get in the way in production or dev modes?

For tests, application.properties in test resources is expected to completely replace the main properties.

Great. I think most people are familiar with that way of defining test properties instead of doin it the Quarkus prefix way with %test. etc

I'll get back to this issue soon. Are you saying the test properties get in the way in production or dev modes?

In the reproducer I only managed to reproduce it when running unit tests, dev is working so far, but in my real project I麓m running into this as well when running in dev mode. I麓ll update the reproducer when I find the cause.

@aloubyansky
After running Gradle clean and doing some changes I got it working (or better, not working) in the reproducer as well.

It seems deleting test/resources/application.properties can be a workaround for tests, but not for running the application with quarkusDev.

Given that the application.properties in test resources completely replaces the main one, you need to move the property to the test application.properties. I did this in your original reproducer and fixed the build.

It does then break the devmode because I actually removed it from the main application.properties.. But if I add it back then it fixes quarkusDev. So it's looking consistent.
This is the relevant PR #8930
Since the behavior looks as expected to me, I am going to close this issue. Let me know in case I missed something. If you find a case where this is messed up, please open a new issue with the corresponding reproducer. Thanks a lot!

I麓m running into this issue again as properties of the submodules are not carried into the actual application. Is this behaviour expected? @aloubyansky

It seems I have do define everything in the application module, but I麓d like to give my library modules default properties that are used across the board and just are overriden ocasionally in the application modules

@mklueh This is expected. The original idea was to have a single source of the config. Your idea is not at all unreasonable. And it's not Gradle-specific. Feel free to open a new issue for it. I'm sure there will be others who will vote for it. Thanks.

Was this page helpful?
0 / 5 - 0 ratings