org.codehaus.groovy.reflection.ReflectionCache

CMD Error :-

Could not initialize class org.codehaus.groovy.reflection.ReflectionCache
Exception java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7

Environment:
Java version: 17.0.8 (LTS)
Gradle version: 8.1.3
OS: Windows 10

Folder Layout

VideoGameDB-master/
├── build.gradle
├── gradlew
├── gradlew.bat
├── settings.gradle
├── pom.xml
├── src/
└── gradle/

With stacktrace

I:\Selenium_IntelliJ\VideoGameDB-master>gradlew clean build --refresh-dependencies --stacktrace

FAILURE: Build failed with an exception.

* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
> Exception java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache [in thread "Daemon worker"]

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
        at org.gradle.internal.extensibility.DefaultExtraPropertiesExtension.<init>(DefaultExtraPropertiesExtension.java:29)

Can you share a build --scan URL?


No URL is getting generated

Never use gradle, but always gradlew.
Best just uninstall Gradle, then you don’t accidentally use the wrong one.

What about gradlew --version?

And please never anywhere share screenshots of text if you only want to share the text and not something additional like colors or IDE annotations. Text in images is hard to read, especially on mobile, very hard to copy, and nearly impossible to search for.

Using gradlew :-

I:\Selenium_IntelliJ\VideoGameDB-master>gradlew build --scan

FAILURE: Build failed with an exception.

* What went wrong:
Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
> Exception java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.reflection.ReflectionCache [in thread "Daemon worker"]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 489ms
--------------------------------------------------------------------------------------
'gradlew' is not recognized as an internal or external command,
operable program or batch file.

I downloaded the ZIP and placed in env path variables in Windows 11 from the following website :-

That is kind of installing, and in 98.7% of cases you should neither do that, not use it, but always the Gadle wrapper.

Besides that, I asked for --version output. :wink:

I am new with gradle, what is gradle wrapper? Please me with this. I am trying to run DB application with API endpoints. Following is the documentation of that :

VideoGameDB

Video Game Database application with API endpoints that support JSON and XML

This application was developed to support my Udemy courses:

Usage

To run the application from the command line, you have two options:

  • Gradle - ./gradlew bootRun
  • Maven - mvn spring-boot:run

When the application is running, open a browser and go to http://localhost:8080/swagger-ui/index.html#/ to explore the API endpoints

-------------------------------------------------------------------------
gradle -version

Welcome to Gradle 8.13!

Here are the highlights of this release:
 - Daemon JVM auto-provisioning
 - Enhancements for Scala plugin and JUnit testing
 - Improvements for build authors and plugin developers

For more details see https://docs.gradle.org/8.13/release-notes.html


------------------------------------------------------------
Gradle 8.13
------------------------------------------------------------

Build time:    2025-02-25 09:22:14 UTC
Revision:      073314332697ba45c16c0a0ce1891fa6794179ff

Kotlin:        2.0.21
Groovy:        3.0.22
Ant:           Apache Ant(TM) version 1.10.15 compiled on August 25 2024
Launcher JVM:  17.0.8 (Oracle Corporation 17.0.8+9-LTS-211)
Daemon JVM:    C:\Program Files\Java\jdk-17 (no JDK specified, using current Java home)
OS:            Windows 11 10.0 amd64

I am new with gradle, what is gradle wrapper?

Asking questions to a community without even trying to Google it yourself is one of the main characteristics of a help vampire!

gradle -version

This is useless and not what I asked for.