Dependencies Load from Unexpected Paths

I am currently upgrading a project from Gradle 6 to Gradle 8. The upgrade also includes changing from Java 11 to 17 and Spring Boot 2 to 3.

Certain integration tests are failing after the upgrade. Setting breakpoints within Java methods shows that there’s an issue loading transitive dependencies. Gradle is looking for some dependencies in their parents’ location in the files cache. I’m showing a screenshot of the error below; my company’s security policies don’t allow for a full build scan.

In the above example, mchange-commons-java is a transitive dependency of c3p0. Grade tries to resolve mchange-commons-java in the c3p0 directory, which only contains files related to c3p0. As such, it fails to find the mchange-commons-java jar and triggers an exception.

Has anybody seen this issue before? Any advice on how to overcome?