quarkusio / quarkus

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

Show nicer error when a `@ConfigMapping` class exists in the `deployment` module and set to the `runtime` phase #43394

Open gastaldi opened 2 months ago

gastaldi commented 2 months ago

Description

While creating (see this PR for more context - https://github.com/quarkusio/quarkus-workshops/pull/600), I noticed that the following error is thrown when the @ConfigMapping phase is set to RUN_TIME:

Caused by: java.lang.ClassNotFoundException: io.quarkus.workshop.superheroes.version.deployment.VersionConfig
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:533)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:481)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:533)
    at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:481)
    at io.quarkus.runtime.configuration.AbstractConfigBuilder.withMapping(AbstractConfigBuilder.java:64)
    ... 21 more

The solution was to move the @ConfigMapping to the runtime module, but the error message is a bit cryptic.

Implementation ideas

It would be nice if we could detect that somehow and display a nicer error message

quarkus-bot[bot] commented 2 months ago

/cc @radcortez (config)

quarkus-bot[bot] commented 2 months ago

You added a link to a Zulip discussion, please make sure the description of the issue is comprehensive and doesn't require accessing Zulip

This message is automatically generated by a bot.

mcruzdev commented 2 months ago

I would like to contribute with this one @gastaldi!

radcortez commented 2 months ago

Feel free to look into it.

This also applies to old @ConfigRoot class objects.