maven-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Petar Tahchiev <>
Subject Classloader issues
Date Wed, 11 Feb 2015 09:03:54 GMT
Hi there,

I have the following maven project setup:

    |----> module1
        |----> class ClassA (has annotation @Annotation)
    |----> module2
        |----> class ClassB (also has annotation @Annotation)

and I'm building it with maven, and I use an AbstractProcessor during
compilation to find all types annotated with @Annotation. When I build it
from the module1 level it all works fine. The problem appears when I build
it from master level. Then, what happens is I get an exception that class B
cannot be found.

Caused by: org.reflections.ReflectionsException: could not get type
for name ClassB
    at org.reflections.ReflectionUtils.forName(
    at org.reflections.ReflectionUtils.forNames(
    at org.reflections.Reflections.getTypesAnnotatedWith(
    at org.reflections.Reflections.getTypesAnnotatedWith(

Here's how I find the types annotated with @Annotation:

 final Reflections reflections =
                        new Reflections(new
                                        new TypeAnnotationsScanner(),
new SubTypesScanner()));
        return reflections.getTypesAnnotatedWith(Annotation.class);

What happens is that the classloader will find all the jars in my pom.xml
AND also the following url:


and then it will be given to Reflections (method scan on line 235 in
Reflections class ) where it will be treated as a SystemDir so reflections
will recursively go thorough all the subfolders and add all the classes it
finds (which also includes module2/target/classes/ClassB.class). Then it
will try to load it and it will produce the error I pasted above. Now i'm
not sure who's passing the master folder to the classpath, but I checked
the maven classpath with -X and I don't see this folder coming from maven.

Any idea who's adding this folder in the classpath, and also how can I
disable adding it?

Thanks a lot.

Regards, Petar!
Karlovo, Bulgaria.
Public PGP Key at:
Key Fingerprint: A369 A7EE 61BC 93A3 CDFF  55A5 1965 8550 C311 0611

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message