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.

Using fast-classpath-scanner in Maven plugin

See original GitHub issue

I am developing Maven plugin (typescript-generator) which is processing classes using reflection and I am using fast-classpath-scanner to get list of class names. It works well but now there is some issue when multi-module Maven project is built in parallel (reported here https://github.com/vojtechhabarta/typescript-generator/issues/142). In this case we get some class name from fast-classpath-scanner which we are not able to load using context class loader.

What I am doing now is:

  • get “CompileClasspath” of the current Maven module
  • create class loader classLoader = new URLClassLoader(CompileClasspath, Thread.currentThread().getContextClassLoader())
  • set it as context classloader Thread.currentThread().setContextClassLoader(classLoader)
  • get list of class names new FastClasspathScanner().scan().getNamesOfClassesWithAnnotation()
  • and then I use Thread.currentThread().getContextClassLoader().loadClass() which sometimes fails

I really don’t know what Maven is doing with classloaders especially in parallel builds but problematic class is from another module which is not in transitive dependencies of current module.

Should I use FastClasspathScanner.overrideClassLoaders() and pass it my context classloader? It seams that my context classloader has “correct” list of classes so probably using FastClasspathScanner.findBestClassLoader() or letting fast-classpath-scanner to load classes is not right solution.

What do you think?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
lukehutchcommented, Jun 16, 2017

Oh, a recent user-submitted change to the Maven setup must have broken the Maven release plug in (it has happened before – it’s quite brittle). I’ll see what I can do to fix that, although I don’t have a lot of Maven expertise!

1reaction
lukehutchcommented, Jun 27, 2017

@vojtechhabarta I’m going to close this, since I think the issue is solved; please open another bug if you still see issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

io.github.lukehutch : fast-classpath-scanner : 3.1.4 - Maven Central ...
Scans the classpath by parsing the classfile binary format directly rather than by using reflection. See https://github.com/lukehutch/fast-classpath-scanner ...
Read more >
java - Unable to scan and collect Entity.class annotated ...
I am using fast-classpath-scanner (v2.18.1 as part of Javers) ... my code given here is using Javers utility class ReflectionUtil.
Read more >
Artifacts using FastClasspathScanner (187) - Maven Repository
Artifacts using FastClasspathScanner (187). Sort: popular | newest ... An extension to Atlassian Plugins that provides a loader that loads plugins into OSGi....
Read more >
Failed to scan the classpath Unknown constant pool tag for ...
When creating a package with Jackson JAXRS Base 2.10.0, ... to execute goal org.apache.jackrabbit:filevault-package-maven-plugin:1.1.0:analyze-classes ...
Read more >
[OSSRH-40533] Timeout while trying to upload jars to Sonatype
I have tried with both nexus-staging-maven-plugin 1.6.3 (which ... /home/luke/Work/fast-classpath-scanner.repo/target/checkout/pom.xml to ...
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