Error:java: java.lang.ExceptionInInitializerError com.sun.tools.javac.code.TypeTags when trying to run maven

Viewed 59201

I'm new to maven but I would like to use it to run simple deeplearing4j program. After adding all the necessary dependencies I get the following:

Error:java: release version 5 not supported

After following the instructions at this page (changing my SDK, language and target byte code to 11)

enter image description here

enter image description here

I'm getting this:

Error:java: java.lang.ExceptionInInitializerError
com.sun.tools.javac.code.TypeTags
Error:java: java.lang.ExceptionInInitializerError

I've also tried setting JDK 14 but I get the same error. Here is my pom.xml file:

<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>Deep</artifactId>
    <version>1.0-SNAPSHOT</version>
    
    <properties>
        <maven.compiler.source>1.11</maven.compiler.source>
        <maven.compiler.target>1.11</maven.compiler.target>
        <dl4j.version>0.9.1</dl4j.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-native-platform</artifactId>
            <version>${dl4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-core</artifactId>
            <version>${dl4j.version}</version>
        </dependency>

        <dependency>
            <groupId>org.datavec</groupId>
            <artifactId>datavec-api</artifactId>
            <version>${dl4j.version}</version>
        </dependency>
        
        <dependency>
            <groupId>org.nd4j</groupId>
            <artifactId>nd4j-api</artifactId>
            <version>1.0.0-beta3</version>
        </dependency>
        
        <dependency>
            <groupId>org.deeplearning4j</groupId>
            <artifactId>deeplearning4j-play_2.11</artifactId>
            <version>0.9.1</version>
        </dependency>
        
    </dependencies>

</project>

If anybody can shed some light on what I might be doing wrong here I would appreciate it.

7 Answers

This is wrong.

<maven.compiler.source>1.11</maven.compiler.source>
<maven.compiler.target>1.11</maven.compiler.target>

Post Java 1.9, the version naming has changed. Make the following changes in the pom.xml.

<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>

The same convention follows from 10+ Java version.

The real issue is: one of library org.deeplearning4j:deeplearning4j-core:jar:0.9.1:compile this jar having a dependency on org.projectlombok:lombok:jar:1.16.16:compile.

So this was an issue with Lombok which they fixed in a later version. To see all transitive dependencies you can do a mvn dependency:tree and see all transitive dependencies of the libraries you have brought in.

I have included the below dependency in the pom and that resolved the issue.

<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>1.18.2</version>
  <scope>provided</scope>
</dependency>

Add this to pom.xml:

<dependency>
  <groupId>org.projectlombok</groupId>
  <artifactId>lombok</artifactId>
  <version>1.18.20</version>
  <scope>provided</scope>
</dependency>

I also got this error, when using jdk 10 to compile java8 source code.

maven compile error

After changing environment variable JAVA_HOME to jdk8 home dir, this error disappear.

It could be a reason of getting this issues while running application Intellij that you haven't configuration Project SDK setting in IDE.

enter image description here

If you're using jdk8 to run your project and still face the same error. Please follow the following 2 steps.

  1. check whether you're able to execute your maven project from IntelliJ's maven bar, instead of from the terminal.
  2. If your project builds then check whether your JAVA_HOME is setup correctly. (In my case I switched from bash to zsh, and JAVA_HOME. was not setup)

I have also faced that problem. Check the JAVA_HOME variable. For ubuntu, go to the terminal and write echo $JAVA_HOME. If you see the difference between this and java -version you will need to set the appropriate version of JDK to your JAVA_HOME like below export JAVA_HOME=YOUR_JDK_BIN_PATH.

I had a similar issue and I was able to solve by changing JDK version from 11 to 8. By the way, this is not running in 8 mode using JDK 11. You actually need a JDK 8 bundle.

Related