quarkusio/quarkus · error · MojoExecutionException
Quarkus code generation phase has failed
Error message
Quarkus code generation phase has failed
What it means
GenerateCodeMojo (the quarkus:generate-code goal) bootstraps a curated application, creates a deployment classloader and reflectively invokes Quarkus initAndRun for code generation. Any exception thrown during that invocation is wrapped in this MojoExecutionException with the original cause attached. The real failure reason is always in the `Caused by` chain.
Source
Thrown at devtools/maven/src/main/java/io/quarkus/maven/GenerateCodeMojo.java:104
CuratedApplication curatedApplication = null;
QuarkusClassLoader deploymentClassLoader = null;
try {
curatedApplication = bootstrapApplication(launchMode);
deploymentClassLoader = curatedApplication.createDeploymentClassLoader();
Thread.currentThread().setContextClassLoader(deploymentClassLoader);
final Class<?> codeGenerator = deploymentClassLoader.loadClass("io.quarkus.deployment.CodeGenerator");
final Method initAndRun = codeGenerator.getMethod("initAndRun", QuarkusClassLoader.class, PathCollection.class,
Path.class, Path.class,
Consumer.class, ApplicationModel.class, Properties.class, String.class,
boolean.class);
initAndRun.invoke(null, deploymentClassLoader, sourceParents,
generatedSourcesDir(test), buildDir().toPath(),
sourceRegistrar, curatedApplication.getApplicationModel(), getBuildSystemProperties(false),
launchMode.name(),
test);
} catch (Exception any) {
throw new MojoExecutionException("Quarkus code generation phase has failed", any);
} finally {
Thread.currentThread().setContextClassLoader(originalTccl);
if (deploymentClassLoader != null) {
deploymentClassLoader.close();
}
// In case of the test mode, we can't share the application model with the test plugins, so we are closing it right away,
// but we are serializing the application model so the test plugins can deserialize it from disk instead of re-initializing
// the resolver and re-resolving it as part of the test bootstrap
if (test && curatedApplication != null) {
var appModel = curatedApplication.getApplicationModel();
injectTestJvmArgsFromDependencies(appModel.getRuntimeDependencies());
closeApplication(LaunchMode.TEST);
if (isSerializeTestModel()) {
final int workspaceId = getWorkspaceId();
if (workspaceId != 0) {
try {View on GitHub (pinned to e1c734241f)
Solutions
- Read the `Caused by` chain of this exception for the root cause and fix that
- Run `./mvnw clean` then regenerate to clear stale generated sources
- Align all io.quarkus dependencies to one platform version via the Quarkus BOM
- Reproduce with `mvn quarkus:generate-code -e` for full stack traces
Example fix
// diagnostic command mvn quarkus:generate-code -e -X # inspect full Caused-by chain
Defensive patterns
Strategy: try-catch
Validate before calling
mvn quarkus:generate-code -e # run the goal first and read the Caused-by chain before packaging
Try / catch
try {
mvn quarkus:generate-code
} catch (MojoExecutionException e) {
Throwable root = e; while (root.getCause() != null) root = root.getCause();
// diagnose root.getMessage()
} Prevention
- Keep all io.quarkus dependencies on one platform version
- Run clean builds after upgrading Quarkus
- Validate quarkus.* configuration before augmentation
When it happens
Trigger: Any Exception (checked or runtime) escaping initAndRun.invoke(...) during `mvn quarkus:generate-code` (also run as part of quarkus:dev and package builds) — e.g. bootstrap/curate failures, config errors, build-step exceptions.
Common situations: Invalid application configuration (unresolvable quarkus.* properties); compilation-dependent generation failures; incompatible extension versions vs. platform BOM; missing classes on the deployment classloader; port/resource conflicts during augmentation.
Related errors
- Failed to bootstrap the application
- Failed to ensure Quarkus Maven version compatibility
- <detected Maven version> is not supported, it must be in <re
- Failed to load CodeGenProvider class from deployment classlo
- Failed to load application configuration
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/443f5bcdd09aaf0e.
Report an issue: GitHub.