Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

367
Views
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

I am getting this exception java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 and java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache) when i run the spring boot application

I am using below tools

STS 3.9.10 release
Open JDK 14 64 bit
Spring boot 2.2.5

It worked fine with oracle jdk but its failing to run with openjdk. I am not using any groovy libs. This is maven based spring boot project.

over 4 years ago · Santiago Trujillo
22 answers
Answer question

0

are you using some third party library that brings in org.codehaus.groovy dependencies? If yes, you can try and replace the required groovy dependencies with the most current releases yourself.

In my case it was the org.liquibase:liquibase-groovy-dsl, so I did this:

    <dependency>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-groovy-dsl</artifactId>
        <version>2.1.1</version>
        <exclusions>
            <exclusion>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-sql</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy</artifactId>
        <version>3.0.3</version>
    </dependency>

    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy-sql</artifactId>
        <version>3.0.3</version>
    </dependency>
over 4 years ago · Santiago Trujillo Report

0

How do you run the application? It's probably because you use Gradle as the build system and JDK14 and the Gradle version is old. Reference: https://github.com/gradle/gradle/issues/10248

If you use Gradle Wrapper then refer to $PROJECT_ROOT/gradle/wrapper/gradle-wrapper.properties. The property distributionUrl should be: distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip

If it's an older version then change it, run ./gradlew clean build and try again.

over 4 years ago · Santiago Trujillo Report

0

Check that your project is running with Java 14 even though it is prepared for Java 8.

My IntelliJ Idea was giving the same error when trying to execute a Gradle task which was running perfectly in command line with JDK 8. The ItelliJ Idea project default JDK was 14 though.

over 4 years ago · Santiago Trujillo Report

0

I resolve this problem when integrated Facebook 7.19.2 and Google play Games 0.10.09.

In my case JDK and SDK using (and other in Edit/Preferences/External -> Tools-Android) default paths Unity:

JDK

C:/ProgramFiles/Unity/Hub/Editor/2019.2.12f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\OpenJDK\Windows

SDK

C:/Program Files/Unity/Hub/Editor/2019.2.12f1/Editor/Data/PlaybackEngines/AndroidPlayer\SDK

In Environmental Variables(System Proporites/Advanced) added next:

Find(or click new variable under User Variables)

  • JAVA_HOME and add root JDK path.

  • JAVA_BIN and add path JDK/bin

  • JAVA_LIB and add path JDK/lib

Also, add these paths in System Variables to variable "Path".

Do not use SDK from default Unity and JDK from not Unity default

Then Restart Unity(and better PC).

Then in Editor Unity - Assets/Play -> Service -> Resolve/Android -> Resolver/Force -> Resolve

All Work fine.

over 4 years ago · Santiago Trujillo Report

0

Got the same issue on a Maven & SpringBoot project, no Gradle whatever.

The dependency to org.codehaus.groovy is probably transitive through spring-cloud-contract-verifier. Run mvn dependency:tree to view the whole dependency tree.

I got it fixed by upgrading the spring-cloud-contract-maven-plugin version to 2.2.3-RELEASE

over 4 years ago · Santiago Trujillo Report

0

If you using Android Studio 4.0 or up and having Errors like below

    Cause: invalid type code: 17
    Cause: invalid type code: fe
    Cause: invalid type code: 13
java.lang.NoClassDefFoundError: Could not initialize class

Or

Its says that something wrong with JDK then Follow below steps to resolve the error.

Step 1: First delete .gradle and .idea folder from project directory and restart Android Studio. Make sure it's gone from recycle bin.

Step 2: Go to Project Structure

Project Structure

Step 3: Select SDK Location from the left panel on Project Structure window.

Step 4: Go to JDK Location and click on down arrow then select the jre instead of jdk

C:\Program Files\Android\Android Studio\jre

JDK Location

And it will Solve the errors. Rebuild the project

Note: jre come with the android studio 4 installation not sure about the older version.

This solution work for me.

over 4 years ago · Santiago Trujillo Report

0

Move to JDK 11, it should work.

over 4 years ago · Santiago Trujillo Report

0

I solved it by editing the gradle-wrapper.properties file inside the gradle folder. (Not .gradle) :

Change this line, from:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip

to:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip

rebuild and it's ok.

over 4 years ago · Santiago Trujillo Report

0

If you are looking for similar solution as @godsim shared, but for gradle liquabase plugin, then modify your configuration section in build.gradle to exclude liquabase's groovy dependency:

configurations {
    ...
    liquibaseRuntime.exclude group: "org.codehaus.groovy"
}

and then manually add groovy in dependencies section:

dependencies {
    ...
    liquibaseRuntime('org.liquibase:liquibase-core:3.8.1')
    liquibaseRuntime('org.codehaus.groovy:groovy-all:3.0.3')
    liquibaseRuntime 'org.postgresql:postgresql'
    liquibaseRuntime('org.liquibase:liquibase-groovy-dsl:2.1.2')
    liquibaseRuntime('org.liquibase.ext:liquibase-hibernate5:3.10.2')
    liquibaseRuntime('org.springframework.boot:spring-boot-starter-data-jpa')
    liquibaseRuntime sourceSets.main.output
    ...
}
over 4 years ago · Santiago Trujillo Report

0

I solved this by selecting Installed JRE path in window => preferences => java => installed JRE => remve existing & select from local directory.

Make sure you have java_home variable set in environmental variable

over 4 years ago · Santiago Trujillo Report

0

in my case, the JRE version used in the Run Configuration was different than the target JDK version in the pom.xml

SpringBoot_Run_Config

over 4 years ago · Santiago Trujillo Report

0

In the file android/gradle/wrapper/gradle-wrapper.properties, ensure that the distributionUrl is as follows:

distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip

Note: If you installed jdk 14

over 4 years ago · Santiago Trujillo Report

0

In my case the combination was IntelliJ 2020.2, Kotlin 1.3.72, Maven 3.6.1 and SpringBoot 2.2.1 application. No Gradle used at all in the project.

Somehow IntelliJ had switched to use OpenJDK14 - when reverting back to OpenJDK11 everything started to work again.

over 4 years ago · Santiago Trujillo Report

0

If you are on Windows operating system and using Android Studio, you should run Android Studio as Administrator.

over 4 years ago · Santiago Trujillo Report

0

I fixed this by adding Apache Groovy 2.4.7 in pom.xml

over 4 years ago · Santiago Trujillo Report

0

For Maven users, Please follow the below steps to resolve this issue

  1. You should place rest-assured before the JUnit dependency declaration in your pom.xml / build.gradle in order to make sure that the correct version of Hamcrest is used.
  2. Add the following dependencies to your pom.xml
<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-all</artifactId>
    <version>3.0.8</version>
    <type>pom</type>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy -->
<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy</artifactId>
    <version>3.0.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-json -->
<dependency>
    <groupId>org.codehaus.groovy</groupId>
    <artifactId>groovy-json</artifactId>
    <version>3.0.8</version>
</dependency>

Hope this will fix your issue. It works for me. Instruction mentioned at step#1 copies from Rest Assured official site. Thanks

over 4 years ago · Santiago Trujillo Report

0

I simply changed the gradle version for the project to the newer version.

a screenshot of the upgrade

PS. I use kotlin

over 4 years ago · Santiago Trujillo Report

0

in my maven Spring Boot project, I solve the problem by adding dependency:

        <!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy -->
    <dependency>
        <groupId>org.codehaus.groovy</groupId>
        <artifactId>groovy</artifactId>
        <version>3.0.8</version>
    </dependency>
over 4 years ago · Santiago Trujillo Report

0

To anyone out there experiencing this error message java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7 when trying to compile a gradle project, try installing an Java SDK. I had to downgrade to SDK 8 in order to compile successfully.

over 4 years ago · Santiago Trujillo Report

0

4 things in IntelliJ to check:

  • Your Project Structure -> Project -> SDK and Language level
  • Settings -> Build,Execution,Deployment -> Build Tools -> Gradle, look at Gradle JVM
  • Settings -> Build,Execution,Deployment -> Compiler -> Java Compiler
  • Your build.gradle, the Java { sourceCompatibility and targetCompatibility }

Make them all agree on the JDK / language level and it should be fine

over 4 years ago · Santiago Trujillo Report

0

This issue is solved for me only when I updated compileSdkVersion and targetSdkVersion to 30 with minSdkVersion 19

over 4 years ago · Santiago Trujillo Report

0

Was getting the error when using old versions of spotbugs-maven-plugin plugin and the corresponding spotbugs maven dependency.

Fixed by upgrading both to 4.2.0.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!