Skip to content

Gradle regression in tests when a module has a "sidecar" module #48159

@celcius112

Description

@celcius112

Describe the bug

From Quarkus 3.22.0 to Quarkus 3.23.0 there is a regression in @QuarkusTest when a module A uses a class from module B that reference a class from module A. In this situation, a ClassNotFoundException is thrown. There is no problem in Quarkus 3.21.4.

Let's say module A has a class Person:

public record Person(String id) {}

And module B a PersonFactory:

public class PersonFactory {
	public static Person newRandomPerson() {
		return new Person(UUID.randomUUID().toString());
	}
}

module A imports B as a test dependency:

dependencies {
    ...
    testImplementation(project(":B"))
    testImplementation("io.quarkus:quarkus-junit5")
}

And module B imports A as a main dependency:

dependencies {
    implementation(project(":A"))
}

If module A uses PersonFactory#newRandomPerson in a @QuarkusTest, a ClassNotFoundException is thrown:

@QuarkusTest
class PersonTest {
	@Test
	void test() {
		PersonFactory.newRandomPerson();
	}
}

With the stacktrace being:

java.lang.NoClassDefFoundError: com/module/Person
	at com.module.test.PersonFactory.newRandomPerson(PersonFactory.java:9)
	at com.module.PersonTest.test(PersonTest.java:12)
	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
	at io.quarkus.test.junit.QuarkusTestExtension.runExtensionMethod(QuarkusTestExtension.java:999)
	at io.quarkus.test.junit.QuarkusTestExtension.interceptTestMethod(QuarkusTestExtension.java:847)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
Caused by: java.lang.ClassNotFoundException: com.module.Person
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:549)
	at io.quarkus.bootstrap.classloading.QuarkusClassLoader.loadClass(QuarkusClassLoader.java:523)
	... 7 more

How to Reproduce?

Here's a reproducer:
test-classloader-issue.zip

  1. Go to PersonFactory and launch the test
    • A ClassNotFoundException should be thrown
  2. In gradle.properties use the Quarkus version 3.21.4
  3. Run the test again
    • The test should pass

Output of uname -a or ver

Darwin MacBook-Pro.local 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6041 arm64

Output of java -version

openjdk version "21.0.5" 2024-10-15 LTS OpenJDK Runtime Environment Temurin-21.0.5+11 (build 21.0.5+11-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.5+11 (build 21.0.5+11-LTS, mixed mode, sharing)

Quarkus version or git rev

3.22.0 to 3.23.0

Build tool (ie. output of mvnw --version or gradlew --version)

Gradle 8.13 and 8.14

Additional information

May be related to #48157, but I am not sure.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions