Hi there, I have the following maven project setup:
master |----> 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(ReflectionUtils.java:389) at org.reflections.ReflectionUtils.forNames(ReflectionUtils.java:398) at org.reflections.Reflections.getTypesAnnotatedWith(Reflections.java:385) at org.reflections.Reflections.getTypesAnnotatedWith(Reflections.java:370) Here's how I find the types annotated with @Annotation: final Reflections reflections = new Reflections(new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader(ClasspathHelper.staticClassLoader())).setScanners( 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: /home/petar/workspace/master/./ 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: https://keyserver1.pgp.com/vkd/DownloadKey.event?keyid=0x19658550C3110611 Key Fingerprint: A369 A7EE 61BC 93A3 CDFF 55A5 1965 8550 C311 0611