Error:java: java.lang.ExceptionInInitializerError IntelliJ

Kavzor picture Kavzor · May 13, 2018 · Viewed 17k times · Source

Heyo!

I've ran into some troubles when attempting to boot up Intellij (ultimate) with JDK 10.0.1 and "spring-boot-starter-test". If I run the main method, regardless of its content and regardless of if I have any active tests I always receive "Error:java: java.lang.ExceptionInInitializerError" after compile, before run.

Summing up, this causes the error

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>

Now I assume this has something to do with spring boot test not being compatible with JDK 10, though I'm prone to ask, any ideas how to solve this?

Update 2 To be clear, this is the ONLY output I receive from Intellij

Information:javac 10.0.1 was used to compile java sources
Information:2018-05-14 21:04 - Compilation completed with 1 error and 0 warnings in 2 s 381 ms
Error:java: java.lang.ExceptionInInitializerError

Build, versions and dependencies here

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.2.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>10</java.version>
</properties>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

Answer

borino picture borino · May 15, 2018

The problem in your case is - Lambook. Lombok does not currently support JDK10. If you comment the dependency the project compiled without errors (i checked).
And here is a full error stack (if you run mvn compile in console):

`Fatal error compiling: java.lang.ExceptionInInitializerError: com.sun.tools.javac.code.TypeTags`