quarkusio/quarkus · error · RuntimeException
Compilation failed.
Error message
Compilation failed.
What it means
The Quarkus Kotlin deployment module invokes the Kotlin compiler (kotlin-compiler-embedder) to compile Kotlin sources during the Quarkus build. The compiler's diagnostics are gathered in a MessageCollector; when the compiler exits with a non-OK exit code and the exit code is COMPILATION_ERROR with errors recorded, this RuntimeException is thrown joining all collected error messages. It means your Kotlin source code failed to compile, not that the Quarkus build itself is broken.
Source
Thrown at extensions/kotlin/deployment/src/main/java/io/quarkus/kotlin/deployment/KotlinCompilationProvider.java:101
compilerArguments.setFreeArgs(filesToCompile.stream().map(File::getAbsolutePath).collect(Collectors.toList()));
final K2JVMCompiler compiler = new K2JVMCompiler();
final Collection<String> compilerOptions = context.getCompilerOptions(KOTLIN_PROVIDER_KEY);
if (compilerOptions != null && !compilerOptions.isEmpty()) {
compiler.parseArguments(compilerOptions.toArray(new String[0]), compilerArguments);
}
final SimpleKotlinCompilerMessageCollector messageCollector = new SimpleKotlinCompilerMessageCollector();
final ExitCode exitCode = compiler.exec(messageCollector, new Services.Builder().build(), compilerArguments);
if (exitCode != ExitCode.OK) {
final String errors = String.join("\n", messageCollector.getErrors());
if (exitCode != ExitCode.COMPILATION_ERROR) {
throw new RuntimeException("Unable to invoke Kotlin compiler. " + errors);
} else if (messageCollector.hasErrors()) {
throw new RuntimeException("Compilation failed. " + errors);
}
}
}
private static class SimpleKotlinCompilerMessageCollector implements MessageCollector {
private final List<String> errors = new ArrayList<>();
@Override
public void clear() {
}
@Override
public boolean hasErrors() {
return !errors.isEmpty();
}
public List<String> getErrors() {View on GitHub (pinned to e1c734241f)
Solutions
- Read the joined error messages in the exception — they contain the Kotlin compiler diagnostics with file:line of each compile error; fix the Kotlin source accordingly
- Run the Kotlin compiler directly (mvn compile or IDE build) to see full diagnostics with quick-fixes
- Check that the Kotlin version (kotlin.version property) is compatible with your JDK and Quarkus version
- If errors come from generated code, clean and rebuild: mvn clean compile
- Ensure kotlin-maven-plugin is configured before/replacing the default compiler for Kotlin sources
Example fix
// before val x: Int = "hello" // type mismatch // after val x: Int = 42
Defensive patterns
Strategy: validation
Validate before calling
// Compile before packaging Quarkus mvn clean compile // or open project in IDE; fix reported Kotlin diagnostics // ensure kotlin version matches JDK: check <kotlin.version> vs java.version in pom.xml
Prevention
- Fix Kotlin errors surfaced in the exception's joined diagnostics (file:line per error)
- Keep kotlin.version aligned with your JDK and Quarkus release
- Run mvn compile in CI before the Quarkus package phase
- Bump Kotlin compiler/stdlib versions together, never independently
When it happens
Trigger: Running a Quarkus build (mvn compile / quarkus:dev) on a project with Kotlin sources that contain syntax errors, unresolved references, type mismatches, or annotations the Kotlin compiler rejects; also when the Kotlin compiler exits with COMPILATION_ERROR.
Common situations: Typos or syntax mistakes introduced while editing .kt files; using a Kotlin language/API feature not supported by the Kotlin version pinned via kotlin-maven-plugin; incompatible kotlin-stdlib vs compiler versions; code generated by Quarkus annotation processing that fails KAPT/KSP; JDK version too new for the embedded Kotlin compiler.
Related errors
- Unable to invoke Kotlin compiler.
- ${archiveRoot} does not point to the application output dire
- errorMessage
- invalid config ${comment}
- Unable to parse: ${resolvedModelPath}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/1673cbfa18eab793.
Report an issue: GitHub.