quarkusio/quarkus · critical · CodeGenException
Failed to load CodeGenProvider class from deployment classlo
Error message
Failed to load CodeGenProvider class from deployment classloader
What it means
CodeGenerator.loadCodeGenProviders() loads the CodeGenProvider class by name from the deployment classloader before using ServiceLoader to discover code-generation providers. If the deployment classloader cannot load io.quarkus.deployment.CodeGenThing.CodeGenProvider (a ClassNotFoundException), it wraps it in a CodeGenException with this message. This indicates a broken or mismatched deployment classpath — the core deployment classes are not visible where code generation runs.
Source
Thrown at core/deployment/src/main/java/io/quarkus/deployment/CodeGenerator.java:162
}
}
}
}
return codeGens;
});
}
@SuppressWarnings("unchecked")
private static List<CodeGenProvider> loadCodeGenProviders(ClassLoader deploymentClassLoader)
throws CodeGenException {
Class<? extends CodeGenProvider> codeGenProviderClass;
try {
//noinspection unchecked
codeGenProviderClass = (Class<? extends CodeGenProvider>) deploymentClassLoader
.loadClass(CodeGenProvider.class.getName());
} catch (ClassNotFoundException e) {
throw new CodeGenException("Failed to load CodeGenProvider class from deployment classloader", e);
}
final Iterator<? extends CodeGenProvider> i = ServiceLoader.load(codeGenProviderClass, deploymentClassLoader)
.iterator();
if (!i.hasNext()) {
return List.of();
}
final List<CodeGenProvider> codeGenProviders = new ArrayList<>();
while (i.hasNext()) {
codeGenProviders.add(i.next());
}
return codeGenProviders;
}
private static <T> T callWithClassloader(ClassLoader deploymentClassLoader, CodeGenAction<T> supplier)
throws CodeGenException {
ClassLoader originalClassloader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(deploymentClassLoader);View on GitHub (pinned to e1c734241f)
Solutions
- Run a clean build with refreshed dependencies (mvn clean, and delete the affected artifacts from ~/.m2 to force re-download).
- Align Quarkus versions: ensure quarkus-maven-plugin/gradle plugin, platform BOM, and core artifacts are all the same version.
- If using a custom classloader/bootstrap, verify quarkus-core-deployment (containing CodeGenProvider) is on the deployment classloader.
- Check the wrapped ClassNotFoundException's missing class name to identify which core artifact is absent and add/restore it.
Example fix
// fix corrupted repo + version alignment
// pom.xml: keep all Quarkus artifacts on one version
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus.platform</groupId>
<artifactId>quarkus-bom</artifactId>
<version>3.x.y</version> <!-- same as plugin -->
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
// then: rm -rf ~/.m2/repository/io/quarkus && mvn clean install Defensive patterns
Strategy: try-catch
Validate before calling
// fail fast with a clear message if the deployment classloader is broken
static void assertCodeGenAvailable(ClassLoader deploymentClassLoader) {
try {
Class.forName("io.quarkus.deployment.codegen.CodeGenProvider", false, deploymentClassLoader);
} catch (ClassNotFoundException e) {
throw new IllegalStateException(
"quarkus-core-deployment is missing from the deployment classloader; "
+ "align Quarkus versions and repair the local Maven repository", e);
}
} Try / catch
try {
List<CodeGenProvider> providers = CodeGenerator.loadCodeGenProviders(deploymentClassLoader, ...);
} catch (CodeGenException e) {
if (e.getMessage().contains("Failed to load CodeGenProvider class")) {
throw new IllegalStateException("Broken deployment classpath: "
+ "verify all Quarkus artifacts share one version and ~/.m2 is not corrupted", e);
}
throw e;
} Prevention
- Pin all Quarkus plugin/BOM/core artifacts to a single version
- Delete and re-download corrupted artifacts from the local repository
- In custom bootstraps, verify quarkus-core-deployment is on the deployment classloader
- Log the ClassNotFoundException cause to identify the missing artifact quickly
When it happens
Trigger: Running Quarkus code generation (build augmentation, dev mode restart, or `quarkus:generate-code`) with a deployment classloader that cannot see quarkus-core-deployment — e.g. corrupted local Maven repository, mixed Quarkus versions on the classpath, or a custom bootstrap that builds a classloader omitting the core deployment module.
Common situations: Corrupted/incomplete ~/.m2 repository after interrupted downloads; mixing Quarkus versions (e.g. old quarkus-maven-plugin with newer platform BOM); custom build tooling or IDE launchers constructing their own deployment classloader; stale shaded/fat-jar layouts missing core deployment classes.
Related errors
- Failed to index: ${className}, class not present in class lo
- Expected : after attribute
- Failed to load application configuration
- Failed to read %s
- Failed to read resources from classpath
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/2a6484539ae6c384.
Report an issue: GitHub.