Note that there are some explanatory texts on larger screens.

plurals
  1. POReflections returning Set with null elements
    text
    copied!<p>I'm using <a href="http://code.google.com/p/reflections/" rel="nofollow">Reflections</a> to find classes that have an specific annotation. My project structure is the following</p> <p>One WAR package: WEB-INF/classes/...packages.../ClassAnnoted1.class</p> <p>One JAR package that is included by the war that has a class that executes this code:</p> <pre><code>Reflections reflections= new Reflections(ClasspathHelper.forWebInfClasses(servletContext)) Set set= reflections.getTypesAnnotatedWith(CustomAnnotation.class) </code></pre> <p>CustomAnnotation is also present on the JAR package.</p> <p>the set size is correct (ie if I have 3 classes with the annotation in my WAR the jar, the set size comes back as 3), but all elements inside it are null instead of Class. I need to get the class and check the annotation parameters inside the class of the JAR.</p> <p>Anyone got any idea of why this is happening?</p> <p>EDIT:</p> <pre><code>Reflections reflections= new Reflections("com.my.customAnnotededClasses"); //package that my annoted class is in Set set= reflections.getTypesAnnotatedWith(CustomAnnotation.class); </code></pre> <p>Also does not work, in this case the set length is zero instead of the number of classes with the annotation.</p> <p>EDIT 2: Ok, the real problem was that I was packaging my whole application as an EAR so I had the following:</p> <pre><code>EAR ----&gt; WAR ----&gt; JAR </code></pre> <p>The jar was included in the EAR lib folder and not on the WAR lib folder. So the jar classes couldn't see the war classes, once i made the WAR depend on the JAR directly like this:</p> <pre><code>EAR ----&gt; WAR ---------&gt; JAR </code></pre> <p>It started working. But the original question still stands, there might be situations where I want the Jar classes included in the EAR instead of the WAR (if i have multiple wars that need to use my jar for instance).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload