question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Classpath scanning does not work in tests using the module path [SPR-16977]

See original GitHub issue

Andy Wilkinson opened SPR-16977 and commented

It appears the classpath scanning doesn’t work when Surefire launches the JVM configured to use the module path. target/classes is placed on the module path and target/test-classes is patched into this module but classpath scanning only finds classes in target/test-classes.

I have attached a minimal sample that should reproduce the problem when built (mvn test) with Java 10. The sysout from the test should show that only the test class has been found:

[INFO] Running com.example.ScanningTest
[file [/Users/awilkinson/dev/temp/module-path-scanning/target/test-classes/com/example/ScanningTest.class]]

To my rather untrained eye, building with -X and examining the arguments that Surefire uses to launch the forked JVM (in target/surefire) suggests that Surefire’s configuration of the JVM is correct.

When the sample is modified to work with Java 8 (remove module-info.java and change the compiler plugin configuration to remove <release>10</release>) the class in target/classes is also found:

[INFO] Running com.example.ScanningTest
[file [/Users/awilkinson/dev/temp/module-path-scanning/target/test-classes/com/example/ScanningTest.class], file [/Users/awilkinson/dev/temp/module-path-scanning/target/classes/com/example/One.class]]

Affects: 5.0.7

Reference URL: https://github.com/spring-projects/spring-boot/issues/13581

Attachments:

Issue Links:

  • #20937 Compatibility with JDK 11

2 votes, 7 watchers

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:26 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
koppercommented, Jun 30, 2020

I had the same (or very similar) issue running tests with maven-failsafe-plugin 3.0.0-M5 on AdoptOpen JDK 11. The work around is to disable using module path in plugin’s configuration <useModulePath>false</useModulePath>

6reactions
eiswindcommented, Dec 28, 2019

Another year has passed. To me this still is a showstopper.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scanning classpath/modulepath in runtime in Java 9
The following code achieves module path scanning in Java 9+ (Jigsaw / JPMS). It finds all classes on the callstack, then for each...
Read more >
3.10 Classpath scanning and managed components - Spring
This section describes an option for implicitly detecting the candidate components by scanning the classpath. Candidate components are classes that match ...
Read more >
module name not found in <mainclass>. module name will be ...
When executing the command mvn javafx:run , the javafx-maven-plugin produces the following: [WARNING] Module name not found in <mainClass>. Module name will ......
Read more >
"Do not use class path" when Run All Tests of a Java module
The proposed "Do not use class path" flag would only heal the symptoms. Here's the failing run configuration: <component name="ProjectRunConfigurationManager"> ...
Read more >
infinitum - Brave New Geek
Implementing Spring-like Classpath Scanning in Android ... The problem with this was that it would still require the module-specific methods to be declared ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found