quarkusio/quarkus · error · CodeGenException
Failed to initialize application configuration
Error message
Failed to initialize application configuration
What it means
CodeGenException thrown by readConfig when the supplied function — most commonly new BuildTimeConfigurationReader(deploymentClassLoader) or configReader.initConfiguration(...) — fails with any Exception. It means Quarkus could not initialize the application's build-time configuration for the code-generation phase. This is the wrapper for essentially all config-mapping/property errors during codegen.
Source
Thrown at core/deployment/src/main/java/io/quarkus/deployment/CodeGenerator.java:356
}
}
// we don't want to load config services from the current module because they haven't been compiled yet
final QuarkusClassLoader.Builder configClBuilder = QuarkusClassLoader.builder("CodeGenerator Config ClassLoader",
deploymentClassLoader, false);
if (!allowedConfigServices.isEmpty()) {
configClBuilder.addNormalPriorityElement(new MemoryClassPathElement(allowedConfigServices, true));
}
if (!bannedConfigServices.isEmpty()) {
configClBuilder.addBannedElement(new MemoryClassPathElement(bannedConfigServices, true));
}
deploymentClassLoader = configClBuilder.build();
Thread.currentThread().setContextClassLoader(deploymentClassLoader);
}
try {
return function.apply(new BuildTimeConfigurationReader(deploymentClassLoader));
} catch (Exception e) {
throw new CodeGenException("Failed to initialize application configuration", e);
} finally {
if (!unavailableConfigServices.isEmpty()) {
Thread.currentThread().setContextClassLoader(originalClassLoader);
deploymentClassLoader.close();
}
}
}
private static Map<String, List<String>> getUnavailableConfigServices(ResolvedDependency dep, ClassLoader classLoader)
throws CodeGenException {
try (OpenPathTree openTree = dep.getContentTree().open()) {
var unavailableServices = new HashMap<String, List<String>>();
openTree.apply(META_INF_SERVICES, visit -> {
if (visit == null) {
// the application module does not include META-INF/services entry. Return `null` here, to let
// MultiRootPathTree.apply() look into all roots.
return null;
}View on GitHub (pinned to e1c734241f)
Solutions
- Read the full 'Caused by' chain — it names the invalid property, missing mapping, or failing source, then fix application.properties or env vars
- Validate build-time property values and types (run quarkus:dev; SmallRye config reports exact property errors)
- After a Quarkus upgrade, check the migration guide for renamed/removed quarkus.* keys (build complains about unknown keys)
- Temporarily remove custom ConfigSource/ConfigSourceFactory implementations to isolate the failure
Example fix
// before (application.properties) quarkus.package.type=war // after: valid enum value for the installed Quarkus version quarkus.package.type=uber-jar
Defensive patterns
Strategy: try-catch
Validate before calling
// Smoke-test build-time config early
try (Config cfg = ConfigProvider.getConfig()) {
for (String name : cfg.getPropertyNames()) {
if (name.startsWith("quarkus.")) cfg.getConfigValue(name); // triggers parsing/validation
}
} Try / catch
try {
return function.apply(new BuildTimeConfigurationReader(deploymentClassLoader));
} catch (CodeGenException e) {
Throwable r = e;
while (r.getCause() != null) r = r.getCause();
throw new IllegalArgumentException("Invalid build-time configuration: " + r.getMessage(), e);
} Prevention
- Read the deepest 'Caused by' — it names the exact invalid property
- After Quarkus upgrades, review the migration guide for removed/renamed config keys
- Use quarkus:dev (fail-fast property validation) before CI builds
- Validate env vars that map to quarkus.* properties (types, enums, levels)
When it happens
Trigger: readConfig invokes function.apply(new BuildTimeConfigurationReader(deploymentClassLoader)); a failure loading/validating @ConfigMapping classes, an invalid build-time property value or type, a missing required build-time property, or an exception while a ConfigSourceFactory runs all surfaces as this message.
Common situations: Typo or wrong type in a quarkus.* build-time property in application.properties; environment variable values that don't parse (e.g. quarkus.log.level=banana); an extension upgrade changed/removed config keys; custom ConfigSource throwing during init; classloading problems from a broken dependency.
Related errors
- Failed to load application configuration
- The configuration ${clazz} is missing the @ConfigMapping ann
- Hibernate Search Standalone activated explicitly, but the Hi
- Unrecognized option for quarkus.bootstrap.misaligned-platfor
- The configuration ${clazz} is missing the @ConfigRoot annota
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/59d5a11902870e64.
Report an issue: GitHub.