When testing the classloaders from within a mojo and a report the following is discovered.
-
- Direct Mojo execution from command line.
mvn -e dummy:dump
Thread.currentThread().getContextClassLoader() = RealmDelegatingClassLoader for dummy:dump.
this.getClass().getClassLoader() = RealmClassLoader for dummy:dump.
-
- Report execution via site:site
mvn -e site:site
Thread.currentThread().getContextClassLoader() = RealmDelegatingClassLoader for site:site.
this.getClass().getClassLoader() = RealmClassLoader for dummy:report.
When a report is executing, relying on the Thread.currentThread().getContextClassLoader() to obtain resources out of jar files (for example) will fail.
This discovery was as a result of debugging MCHECKSTYLE-10
Either the Thread.currentThread().getContextClassLoader() should be the one for the specific report, or there should be a gotcha for report developers to use this.getClass().getClassLoader() instead.
But that kind of limitation could pose problems for classloader issues in non-reports, such as checkstyle internals, or commons-logging internals.