quarkusio/quarkus · error · GradleException
Quarkus code generation phase has failed
Error message
Quarkus code generation phase has failed
What it means
CodeGenWorker runs Quarkus code generation (e.g. REST/gRPC/Avro stub generation) by reflectively loading CodeGenerator.initAndRun from a QuarkusClassLoader. This GradleException is thrown when the reflective getMethod lookup for INIT_AND_RUN fails (NoSuchMethodException or related), meaning the code generator class found on the generated-resources classpath does not expose the expected method signature — usually a Quarkus/plugin version mismatch or a corrupted code-generation cache.
Source
Thrown at devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/tasks/worker/CodeGenWorker.java:58
LOGGER.info("Generating Quarkus code for {}", gav);
LOGGER.info(" launch mode: {}", params.getLaunchMode().get());
LOGGER.info(" base name: {}", params.getBaseName().get());
LOGGER.info(" generated source directory: {}", generatedSourceDir);
LOGGER.info(" build directory: {}", buildDir);
try (CuratedApplication appCreationContext = createAppCreationContext()) {
QuarkusClassLoader deploymentClassLoader = appCreationContext.createDeploymentClassLoader();
Class<?> codeGenerator = deploymentClassLoader.loadClass(CodeGenerator.class.getName());
Method initAndRun;
try {
initAndRun = codeGenerator.getMethod(INIT_AND_RUN, QuarkusClassLoader.class, PathCollection.class,
Path.class, Path.class,
Consumer.class, ApplicationModel.class, Properties.class, String.class,
boolean.class);
} catch (Exception e) {
throw new GradleException("Quarkus code generation phase has failed", e);
}
Consumer<Path> sourceRegistrar = (p) -> {
};
LaunchMode launchMode = params.getLaunchMode().get();
initAndRun.invoke(null,
// QuarkusClassLoader classLoader,
deploymentClassLoader,
// PathCollection sourceParentDirs,
PathList.from(
params.getSourceDirectories().getFiles().stream().map(File::toPath).collect(Collectors.toList())),
// Path generatedSourcesDir,
generatedSourceDir,
// Path buildDir,
buildDir,
// Consumer<Path> sourceRegistrar,View on GitHub (pinned to e1c734241f)
Solutions
- Align all Quarkus plugin, core, and extension versions to the same release.
- Clean generated caches: ./gradlew clean, or delete build/generated-sources, then re-run quarkusGenerateCode.
- Stop and restart the Gradle daemon (./gradlew --stop) to drop stale classloader state.
- Run with --info/--debug to see which CodeGenerator class was loaded and from which jar.
Defensive patterns
Strategy: validation
Validate before calling
./gradlew --stop # clear stale daemon classloaders rm -rf build/generated-sources # remove stale codegen output # then rebuild with aligned versions
Prevention
- Always upgrade the whole Quarkus stack (plugin + core + extensions) together
- Clean generated-sources after any Quarkus version change
- Avoid pinning individual Quarkus extensions to older versions than the BOM
- Restart the Gradle daemon after upgrading build plugins
When it happens
Trigger: Running ./gradlew quarkusGenerateCode when the resolved CodeGenerator class does not declare initAndRun(QuarkusClassLoader, PathCollection, Path, Path, Consumer, ApplicationModel, Properties, String, boolean) — caused by mismatched quarkus-core vs extension generator versions, a stale build/generated-sources cache, or the wrong class being loaded from the classloader.
Common situations: Upgrading Quarkus BOM partially (some extensions pinned to old versions); stale build/ directory after an upgrade; Gradle daemon caching an old codegen jar; classpath pollution where an incompatible CodeGenerator implementation shadows the right one.
Related errors
- Failed to generate sources in the QuarkusGenerateCode task f
- Didn't find method
- Failed to call method
- Unexpected mode:
- Unable to find the following conversion class: ${customConve
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/89822682e027f284.
Report an issue: GitHub.