Pavel Molchanov
Pavel Molchanov

Reputation: 2409

Maven build error "Missing ... kotlin/reflect/full/KClasses"

I have created a simple application with Spring Boot Initializr to try REST controllers.

Kotlin version was specified as 1.3.50 automatically.

Maven pom.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.infodesk</groupId>
    <artifactId>shopper</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>shopper</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
        <kotlin.version>1.3.50</kotlin.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-kotlin</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-reflect</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
        <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <configuration>
                    <args>
                        <arg>-Xjsr305=strict</arg>
                    </args>
                    <compilerPlugins>
                        <plugin>spring</plugin>
                    </compilerPlugins>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.jetbrains.kotlin</groupId>
                        <artifactId>kotlin-maven-allopen</artifactId>
                        <version>${kotlin.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

</project>

I got Maven Plugin error after building the project:

[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.3.50:compile (compile) on project shopper: Execution compile of goal org.jetbrains.kotlin:kotlin-maven-plugin:1.3.50:compile failed: A required class was missing while executing org.jetbrains.kotlin:kotlin-maven-plugin:1.3.50:compile: kotlin/reflect/full/KClasses
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.jetbrains.kotlin:kotlin-maven-plugin:1.3.50
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/kotlin/kotlin-maven-plugin/1.3.50/kotlin-maven-plugin-1.3.50.jar
[ERROR] urls[1] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/kotlin/kotlin-maven-allopen/1.3.50/kotlin-maven-allopen-1.3.50.jar
[ERROR] urls[2] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.3.50/kotlin-stdlib-1.3.50.jar
[ERROR] urls[3] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.50/kotlin-stdlib-common-1.3.50.jar
[ERROR] urls[4] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/annotations/13.0/annotations-13.0.jar
[ERROR] urls[5] = file:/C:/Users/pavel.molchanov/.m2/repository/org/sonatype/aether/aether-util/1.13.1/aether-util-1.13.1.jar
[ERROR] urls[6] = file:/C:/Users/pavel.molchanov/.m2/repository/org/sonatype/sisu/sisu-inject-bean/2.3.0/sisu-inject-bean-2.3.0.jar
[ERROR] urls[7] = file:/C:/Users/pavel.molchanov/.m2/repository/org/sonatype/sisu/sisu-guice/3.1.0/sisu-guice-3.1.0-no_aop.jar
[ERROR] urls[8] = file:/C:/Users/pavel.molchanov/.m2/repository/org/sonatype/sisu/sisu-guava/0.9.9/sisu-guava-0.9.9.jar
[ERROR] urls[9] = file:/C:/Users/pavel.molchanov/.m2/repository/org/codehaus/plexus/plexus-interpolation/1.14/plexus-interpolation-1.14.jar
[ERROR] urls[10] = file:/C:/Users/pavel.molchanov/.m2/repository/org/codehaus/plexus/plexus-utils/2.0.6/plexus-utils-2.0.6.jar
[ERROR] urls[11] = file:/C:/Users/pavel.molchanov/.m2/repository/org/codehaus/plexus/plexus-component-annotations/1.5.5/plexus-component-annotations-1.5.5.jar
[ERROR] urls[12] = file:/C:/Users/pavel.molchanov/.m2/repository/org/sonatype/plexus/plexus-sec-dispatcher/1.3/plexus-sec-dispatcher-1.3.jar
[ERROR] urls[13] = file:/C:/Users/pavel.molchanov/.m2/repository/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher-1.4.jar
[ERROR] urls[14] = file:/C:/Users/pavel.molchanov/.m2/repository/org/apache/maven/plugin-tools/maven-plugin-annotations/3.4/maven-plugin-annotations-3.4.jar
[ERROR] urls[15] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/kotlin/kotlin-compiler/1.3.50/kotlin-compiler-1.3.50.jar
[ERROR] urls[16] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/kotlin/kotlin-script-runtime/1.3.50/kotlin-script-runtime-1.3.50.jar
[ERROR] urls[17] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/kotlin/kotlin-reflect/1.3.50/kotlin-reflect-1.3.50.jar
[ERROR] urls[18] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/intellij/deps/trove4j/1.0.20181211/trove4j-1.0.20181211.jar
[ERROR] urls[19] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler/1.3.50/kotlin-scripting-compiler-1.3.50.jar
[ERROR] urls[20] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-common/1.3.50/kotlin-scripting-common-1.3.50.jar
[ERROR] urls[21] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core/1.1.1/kotlinx-coroutines-core-1.1.1.jar
[ERROR] urls[22] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-jvm/1.3.50/kotlin-scripting-jvm-1.3.50.jar
[ERROR] urls[23] = file:/C:/Users/pavel.molchanov/.m2/repository/org/jetbrains/kotlin/kotlin-scripting-compiler-impl/1.3.50/kotlin-scripting-compiler-impl-1.3.50.jar
[ERROR] urls[24] = file:/C:/Users/pavel.molchanov/.m2/repository/org/apache/maven/plugins/maven-compiler-plugin/3.5.1/maven-compiler-plugin-3.5.1.jar
[ERROR] urls[25] = file:/C:/Users/pavel.molchanov/.m2/repository/org/apache/maven/shared/maven-shared-utils/3.0.0/maven-shared-utils-3.0.0.jar
[ERROR] urls[26] = file:/C:/Users/pavel.molchanov/.m2/repository/commons-io/commons-io/2.4/commons-io-2.4.jar
[ERROR] urls[27] = file:/C:/Users/pavel.molchanov/.m2/repository/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar
[ERROR] urls[28] = file:/C:/Users/pavel.molchanov/.m2/repository/org/apache/maven/shared/maven-shared-incremental/1.1/maven-shared-incremental-1.1.jar
[ERROR] urls[29] = file:/C:/Users/pavel.molchanov/.m2/repository/org/codehaus/plexus/plexus-compiler-api/2.7/plexus-compiler-api-2.7.jar
[ERROR] urls[30] = file:/C:/Users/pavel.molchanov/.m2/repository/org/codehaus/plexus/plexus-compiler-manager/2.7/plexus-compiler-manager-2.7.jar
[ERROR] urls[31] = file:/C:/Users/pavel.molchanov/.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] -----------------------------------------------------: kotlin.reflect.full.KClasses
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

If I downgrade Kotlin to 1.3.41, the error goes away and project builds successfully.

What is the problem with 1.3.50?

Upvotes: 2

Views: 2552

Answers (1)

Neikius
Neikius

Reputation: 163

You have a missing class problem. Something is using it during the build so hence the error. That class should be in kotlin-reflect jar. It is in mine. I would try clearing m2 cache or just deleting the kotlin-reflect 1.3.50 jar. It sometimes happen that you get a damaged jar and maven can't seem to figure that out.

Funnily enough I got the exact same problem with kotlin 1.3.60 and this was the cause.

Upvotes: 3

Related Questions