I am uploading a jar dynamically through servlet and saving it in my WEB-INF/lib directory. I want to get all the classes annotated with my @annotation,
have used reflections code below without any luck.. the manifest of the jar is readble but the classes are not.. the list of classes is 0
List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>();
classLoadersList.add(ClasspathHelper.contextClassLoader());
classLoadersList.add(ClasspathHelper.staticClassLoader());
ConfigurationBuilder builder = new ConfigurationBuilder().setScanners(new SubTypesScanner(false), new ResourcesScanner(),
new TypeAnnotationsScanner());
Set<URL> set = ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0]));
FilterBuilder filterBuilder = new FilterBuilder().include(FilterBuilder.prefix(exportPackage));
Reflections reflections = new Reflections(builder.setUrls(set).filterInputsBy(filterBuilder));
Set<Class<? extends Object>> classSet = reflections.getTypesAnnotatedWith(MyAnnotation.class);
What changes to the configuration will help get the classes from the jar that is dynamically uploaded..