spring-bootgradletestingjava-17

Not found or load worker.org.gradle.process.internal.worker.GradleWorkerMain when run test with Gradle


I have a project API REST with Java 17, Spring Boot 3.3.0 and Gradle 8.9. This project run without problems but when I try to run the test with the command ./gradlew test or with IDE and I get this error when was do the build:

Could not write standard input to Gradle Test Executor 5. java.io.IOException: The pipeline is being closed....

The main class
**worker.org.gradle.process.internal.worker.GradleWorkerMain** could not be found or loaded

These are some configs of the project

build.gradle

plugins {
    id 'java'
    id 'application'
    id 'org.springframework.boot' version '3.3.0'
    id 'io.spring.dependency-management' version '1.1.5'
}

group = 'org.example'
version = '1.0.0'

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}

application {
    mainClass = 'org.examplesolid.ExampleSolidApplication'
}

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

dependencies {
    compileOnly 'org.projectlombok:lombok'
    annotationProcessor 'org.projectlombok:lombok'
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.17.1'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    implementation 'org.modelmapper:modelmapper:2.3.8'
    implementation 'org.modelmapper:modelmapper-module-record:1.0.0'
    implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0'
    implementation 'mysql:mysql-connector-java:8.0.31'
    runtimeOnly 'com.h2database:h2:2.2.224'
    testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
    testImplementation 'io.projectreactor:reactor-test'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3'
    testImplementation 'org.mockito:mockito-junit-jupiter:5.11.0'
    testImplementation 'org.assertj:assertj-core:3.25.3'
    testAndDevelopmentOnly 'com.h2database:h2:2.2.224'
}

repositories {
    mavenCentral()
}

tasks.named('test', Test) {
    useJUnitPlatform()
}

gradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

config Gradle in IntelliJ

I also try to fix the error changing Gradle version to 8.9 and 8.8, but I couldn't fix it, some commands that I used:

./gradlew --stop

./gradlew wrapper --gradle-version 8.9

.\gradlew clean build --refresh-dependencies

I don't know what other information is needed. If there is anything else important that you need to know to help me solve this, please let me know.

Thanks for help and time to read


Solution

  • I solved my problem clean the cache of the project (Gradle and IntelliJ) and rebuild and config the IDE tool of build (Gradle). I think the problem was trying to change Gradle version but have conflicts with the cache of IDE (IntelliJ - .idea folder)