quarkusio/quarkus · error · CodeGenException
e.getMessage() (rethrow of code generation failure)
Error message
e.getMessage() (rethrow of code generation failure)
What it means
extractProtosFromArtifact catches its own GrpcCodeGenException and rethrows it as a generic io.quarkus.deployment.CodeGenException with the same message, preserving the cause. This is the wrapping boundary developers actually see in build logs; the root message will be one of the more specific 'Failed to create directory' or 'Failed to extract proto file' errors.
Source
Thrown at extensions/grpc/codegen/src/main/java/io/quarkus/grpc/codegen/GrpcCodeGen.java:436
throw new GrpcCodeGenException("Failed to create directory: " + protoOutputDir, e);
}
Path outPath = protoOutputDir.resolve(strippedPathStr);
try {
Files.createDirectories(outPath.getParent());
if (isDependency) {
copySanitizedProtoFile(artifact, path, outPath);
} else {
Files.copy(path, outPath, StandardCopyOption.REPLACE_EXISTING);
}
protoFiles.add(outPath);
} catch (IOException e) {
throw new GrpcCodeGenException("Failed to extract proto file" + path + " to target: "
+ outPath, e);
}
}
});
} catch (GrpcCodeGenException e) {
throw new CodeGenException(e.getMessage(), e);
}
}
private static String stripProtoPrefix(String relativePathStr) {
if (relativePathStr.startsWith(SRC_MAIN_PROTO_DIR)) {
return relativePathStr.substring(SRC_MAIN_PROTO_DIR.length());
}
if (relativePathStr.startsWith(SRC_TEST_PROTO_DIR)) {
return relativePathStr.substring(SRC_TEST_PROTO_DIR.length());
}
if (relativePathStr.startsWith(PROTO_DIR)) {
return relativePathStr.substring(PROTO_DIR.length());
}
return relativePathStr;
}
private static Path getProtoOutputDir(Path workDir, ResolvedDependency artifact) {
String uniqueName = artifact.getGroupId() + ":" + artifact.getArtifactId();View on GitHub (pinned to e1c734241f)
Solutions
- Read the caused-by chain: the root GrpcCodeGenException/IOException names the real problem (permissions, missing file, disk)
- Run mvn clean / gradle clean and rebuild to clear stale generated output
- Fix the underlying IO condition (writable target dir, intact artifact JAR) rather than the CodeGenException itself
- If it reproduces on a good checkout, pin/refresh the dependency containing the proto files
Defensive patterns
Strategy: try-catch
Try / catch
try {
quarkusBuild.perform();
} catch (CodeGenException e) {
// always inspect the cause chain — this exception wraps a GrpcCodeGenException/IOException
Throwable root = e;
while (root.getCause() != null) root = root.getCause();
log.error("gRPC codegen failed, root cause: " + root.getMessage(), e);
} Prevention
- Read the full stack trace, not just the top-level CodeGenException message
- Reproduce with a clean checkout before blaming environment
- Keep Quarkus and platform BOM versions aligned
When it happens
Trigger: Any failure inside proto extraction (directory creation or file copy during scanning of dependency protos) surfaces as this CodeGenException during the generate-code phase of quarkus:dev, mvn compile, or a Quarkus build.
Common situations: Same underlying causes as the wrapped errors: unwritable build directory, locked or corrupted dependency JARs, disk space, long Windows paths — plus confusing stack traces where the top-level CodeGenException hides the IO detail.
Related errors
- Failed to generate Java classes from proto files: %s to %s w
- Failed to generate java files from proto file in " + inputDi
- Failed to create directory: " + protoOutputDir
- Failed to extract proto file" + path + " to target: " + outP
- Failed to find ${location} among dependencies
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/4cedf67a1068664d.
Report an issue: GitHub.