Kotlin 1.2.50: Compile failed: A required class was missing: kotlin/reflect/KDeclarationContainer

I have a very similar problem to the one described here

I have a Maven project that compiles fine under IntelliJ, but when I try to compile it with Maven on the command line when using Kotlin 1.2.50 or higher, I get this error:

kotlin-maven-plugin:1.2.51:compile failed: A required class was missing while executing org.jetbrains.kotlin:kotlin-maven-plugin:1.2.51:compile: kotlin/reflect/KDeclarationContainer

[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.2.51:compile (compile) on project myproj: 
Execution compile of goal org.jetbrains.kotlin:kotlin-maven-plugin:1.2.51:compile failed: 
A required class was missing while executing org.jetbrains.kotlin:kotlin-maven-plugin:1.2.51:compile: kotlin/reflect/KDeclarationContainer
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.jetbrains.kotlin:kotlin-maven-plugin:1.2.51
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/home/user/.m2/repository/org/jetbrains/kotlin/kotlin-maven-plugin/1.2.51/kotlin-maven-plugin-1.2.51.jar
[ERROR] urls[1] = file:/home/user/.m2/repository/org/sonatype/aether/aether-util/1.13.1/aether-util-1.13.1.jar
[ERROR] urls[2] = file:/home/user/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.3.0/sisu-inject-bean-2.3.0.jar
[ERROR] urls[3] = file:/home/user/.m2/repository/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar
[ERROR] urls[4] = file:/home/user/.m2/repository/org/sonatype/sisu/sisu-guava/0.9.9/sisu-guava-0.9.9.jar
[ERROR] urls[5] = file:/home/user/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[6] = file:/home/user/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar
[ERROR] urls[7] = file:/home/user/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[8] = file:/home/user/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[9] = file:/home/user/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[10] = file:/home/user/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.4/maven-plugin-annotations-3.4.jar
[ERROR] urls[11] = file:/home/user/.m2/repository/org/jetbrains/kotlin/kotlin-compiler/1.2.51/kotlin-compiler-1.2.51.jar
[ERROR] urls[12] = file:/home/user/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler/1.2.51/kotlin-scripting-compiler-1.2.51.jar
[ERROR] urls[13] = file:/home/user/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/3.5.1/maven-compiler-plugin-3.5.1.jar
[ERROR] urls[14] = file:/home/user/.m2/repository/org/apache/maven/shared/maven-shared-utils/3.0.0/maven-shared-utils-3.0.0.jar
[ERROR] urls[15] = file:/home/user/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
[ERROR] urls[16] = file:/home/user/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
[ERROR] urls[17] = file:/home/user/.m2/repository/org/apache/maven/shared/maven-shared-incremental/1.1/maven-shared-incremental-1.1.jar
[ERROR] urls[18] = file:/home/user/.m2/repository/org/codehaus/plexus/plexus-compiler-api/2.7/plexus-compiler-api-2.7.jar
[ERROR] urls[19] = file:/home/user/.m2/repository/org/codehaus/plexus/plexus-compiler-manager/2.7/plexus-compiler-manager-2.7.jar
[ERROR] urls[20] = file:/home/user/.m2/repository/org/codehaus/plexus/plexus-compiler-javac/2.7/plexus-compiler-javac-2.7.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] : kotlin.reflect.KDeclarationContainer
[ERROR] -> [Help 1]

This error doesn’t happen under Kotlin 1.2.41

Any ideas on how to fix this?

Can you please create an issue on http://kotl.in/issue and attach your project (can be done privately) so we can try to reproduce this problem?

Problem solved in Kotlin 1.2.60 :smile:

1 Like

Re-surfaced in kotlin 1.2.70

[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.2.70:compile (compile) on project etraveli-codestyle: Execution compile of goal org.jetbrains.kotlin:kotlin-maven-plugin:1.2.70:compile failed: A required class was missing while executing org.jetbrains.kotlin:kotlin-maven-plugin:1.2.70:compile: kotlin/reflect/KDeclarationContainer
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.jetbrains.kotlin:kotlin-maven-plugin:1.2.70
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/lj/.m2/repository/org/jetbrains/kotlin/kotlin-maven-plugin/1.2.70/kotlin-maven-plugin-1.2.70.jar
[ERROR] urls[1] = file:/Users/lj/.m2/repository/org/jetbrains/kotlin/kotlin-maven-noarg/1.2.70/kotlin-maven-noarg-1.2.70.jar
[ERROR] urls[2] = file:/Users/lj/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.2.70/kotlin-stdlib-1.2.70.jar
[ERROR] urls[3] = file:/Users/lj/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.2.70/kotlin-stdlib-common-1.2.70.jar
[ERROR] urls[4] = file:/Users/lj/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar
[ERROR] urls[5] = file:/Users/lj/.m2/repository/org/sonatype/aether/aether-util/1.13.1/aether-util-1.13.1.jar
[ERROR] urls[6] = file:/Users/lj/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.3.0/sisu-inject-bean-2.3.0.jar
[ERROR] urls[7] = file:/Users/lj/.m2/repository/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar
[ERROR] urls[8] = file:/Users/lj/.m2/repository/org/sonatype/sisu/sisu-guava/0.9.9/sisu-guava-0.9.9.jar
[ERROR] urls[9] = file:/Users/lj/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[10] = file:/Users/lj/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar
[ERROR] urls[11] = file:/Users/lj/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[12] = file:/Users/lj/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[13] = file:/Users/lj/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[14] = file:/Users/lj/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.4/maven-plugin-annotations-3.4.jar
[ERROR] urls[15] = file:/Users/lj/.m2/repository/org/jetbrains/kotlin/kotlin-compiler/1.2.70/kotlin-compiler-1.2.70.jar
[ERROR] urls[16] = file:/Users/lj/.m2/repository/org/jetbrains/kotlin/kotlin-script-runtime/1.2.70/kotlin-script-runtime-1.2.70.jar
[ERROR] urls[17] = file:/Users/lj/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.2.70/kotlin-reflect-1.2.70.jar
[ERROR] urls[18] = file:/Users/lj/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler/1.2.70/kotlin-scripting-compiler-1.2.70.jar
[ERROR] urls[19] = file:/Users/lj/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-common/1.2.70/kotlin-scripting-common-1.2.70.jar
[ERROR] urls[20] = file:/Users/lj/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core/0.20/kotlinx-coroutines-core-0.20.jar
[ERROR] urls[21] = file:/Users/lj/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jvm/1.2.70/kotlin-scripting-jvm-1.2.70.jar
[ERROR] urls[22] = file:/Users/lj/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-misc/1.2.70/kotlin-scripting-misc-1.2.70.jar
[ERROR] urls[23] = file:/Users/lj/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/3.5.1/maven-compiler-plugin-3.5.1.jar
[ERROR] urls[24] = file:/Users/lj/.m2/repository/org/apache/maven/shared/maven-shared-utils/3.0.0/maven-shared-utils-3.0.0.jar
[ERROR] urls[25] = file:/Users/lj/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
[ERROR] urls[26] = file:/Users/lj/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
[ERROR] urls[27] = file:/Users/lj/.m2/repository/org/apache/maven/shared/maven-shared-incremental/1.1/maven-shared-incremental-1.1.jar
[ERROR] urls[28] = file:/Users/lj/.m2/repository/org/codehaus/plexus/plexus-compiler-api/2.7/plexus-compiler-api-2.7.jar
[ERROR] urls[29] = file:/Users/lj/.m2/repository/org/codehaus/plexus/plexus-compiler-manager/2.7/plexus-compiler-manager-2.7.jar
[ERROR] urls[30] = file:/Users/lj/.m2/repository/org/codehaus/plexus/plexus-compiler-javac/2.7/plexus-compiler-javac-2.7.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]

Hello, is it possible for you to share your project and attach it to a YouTrack issue?

I’m getting the same problem with 1.3.21; going back to 1.3.20 solved the problem.

1 Like