How to dynamically scan Annotated classes using google Reflections?
<p>In refrence to <a href="https://stackoverflow.com/questions/259140/scanning-java-annotations-at-runtime">this</a>. I am making an hibernate demo in which I want to map all the POJO classes dynamically. I found the above given reference and tried to scan my classes from the package mapping only. But it is giving some errors like:</p>

<pre><code>Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/base/Predicate
at com.telemune.util.StringUtil.getSessionFactory(StringUtil.java:44)
at com.telemune.generator.TableDescriber.describeTable(TableDescriber.java:33)
at com.telemune.generator.PojoGenerator.main(PojoGenerator.java:169)
Caused by: java.lang.ClassNotFoundException: com.google.common.base.Predicate
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
... 3 more
</code></pre>

<p>when I added <strong>com.google.common_1.0.0.201004262004.jar</strong> I got this:</p>

<pre><code> Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.copyOf(Ljava/util/Collection;)Lcom/google/common/collect/ImmutableSet;
at org.reflections.Reflections.getTypesAnnotatedWith(Reflections.java:358)
at com.telemune.util.StringUtil.getSessionFactory(StringUtil.java:46)
at com.telemune.generator.TableDescriber.describeTable(TableDescriber.java:33)
at com.telemune.generator.PojoGenerator.main(PojoGenerator.java:169)
</code></pre>

<p>I am not able to ask or comment there that's why I am asking it here specially to @MartinAubele, @Jonathan, @SergeyBrunov, @ArthurRonald. Please give an example or something by which I can use google-reflections to scan my package.</p>

<p>Please <strong>Note:</strong> I don't want to use Spring. So please don't suggest about that. Thanks in Advance.</p>

<p>some code Sample:</p>

<pre><code>SessionFactory sfactory = null;
ServiceRegistry serviceRegistry=null;
Configuration configuration = new Configuration().configure("hibernate.cfg.xml");
Reflections reflections = new Reflections(PojoGenerator.pkgName);
Set&lt;Class&lt;?&gt;&gt; classes = reflections.getTypesAnnotatedWith(javax.persistence.Entity.class);
for(Class&lt;?&gt; clazz : classes)
{
    configuration.addAnnotatedClass(clazz);
}
serviceRegistry = new StandardServiceRegistryBuilder().applySettings(configuration.getProperties()).build();

    sfactory = configuration.buildSessionFactory();
</code></pre>

<p>and <strong>another problem</strong> is :
<strong>configuration.buildSessionFactory();</strong> is not allowing me to use 
<strong>configuration.buildSessionFactory(serviceRegistry);</strong></p>