Skip to content

Cannot run Quarkus tasks with dependencies from an external project using Gradle composite build #47734

@n-hass

Description

@n-hass

Describe the bug

When using a Gradle composite build, if an includeBuild supplies a JAR with an external dependency that is common with the Quarkus project, it may cause classloader issues.

ClassCastException: class MyClass$$serializer cannot be cast to class kotlinx.serialization.SerializationStrategy (MyClass$$serializer is in unnamed module of loader 'app'; kotlinx.serialization.SerializationStrategy is in unnamed module of loader io.quarkus.bootstrap.classloading.QuarkusClassLoader @dcfda20)`

I have only observed this with kotlinx-serialization on the following reproducer: https://github.com/n-hass/quarkus-issue-47430
It can be replicated by running the quarkusTest task on :application-server:services:foo.

The layout is as so:

Project A
├── includes: Project B
│   └── uses: kotlinx-serialization
└── uses: kotlinx-serialization

Expected behavior

A dependency on an includeBuild artifact does not cause a ClassCastException when using it in Quarkus

Actual behavior

kolinx-serialization's generated classes are being loaded using the system classloader, whilst the project's serialization dependency in the quarkus classloader, causing the exception.

How to Reproduce?

  1. Clone https://github.com/n-hass/quarkus-issue-47430
  2. run ./gradlew :application-server:services:foo:quarkusTest

Output of uname -a or ver

Darwin NM 24.4.0 Darwin Kernel Version 24.4.0: Fri Apr 11 18:32:50 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T6041 arm64 arm Darwin

Output of java -version

openjdk version "21.0.4" 2024-07-16 LTS OpenJDK Runtime Environment Zulu21.36+17-CA (build 21.0.4+7-LTS) OpenJDK 64-Bit Server VM Zulu21.36+17-CA (build 21.0.4+7-LTS, mixed mode, sharing)

Quarkus version or git rev

3.20.0

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

8.13

Additional information

#47730 fixes the test part of the reproducer provided by @n-hass but not the quarkusTest one, unfortunately. We'll need to investigate it further.

Originally posted by @aloubyansky in #47430

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions