Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:java: java.lang.ExceptionInInitializerError IntelliJ

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>
like image 769
Kavzor Avatar asked May 13 '18 11:05

Kavzor


People also ask

How do I resolve Java Lang ExceptionInInitializerError null?

We can resolve the java. lang. ExceptionInInitializerError by ensuring that static initializer block of classes does not throw any Runtime Exception. We can resolve also resolve this exception by ensuring that the initializing static variable of classes also doesn't throw any Runtime Exception.

What causes Java Lang ExceptionInInitializerError?

Class ExceptionInInitializerError. Signals that an unexpected exception has occurred in a static initializer. An ExceptionInInitializerError is thrown to indicate that an exception occurred during evaluation of a static initializer or the initializer for a static variable.


2 Answers

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`

like image 50
borino Avatar answered Oct 02 '22 00:10

borino


Update Lombok to the newest version. Helped in my case Here is a link with the newest Lombok https://projectlombok.org/download Optionally modify the .pom file in Your project (by changing the name of the lombok version).

like image 43
Andrzej Kwiecinski Avatar answered Oct 01 '22 22:10

Andrzej Kwiecinski