Entity scanning not working in JPA/hibernate/spring application
<p>My <code>applicationContext.xml</code>is:</p>

<pre><code>&lt;aop:aspectj-autoproxy/&gt;

&lt;context:component-scan base-package="com"/&gt;
&lt;context:annotation-config/&gt;

&lt;bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/&gt;
&lt;tx:jta-transaction-manager/&gt;
&lt;tx:annotation-driven/&gt;

&lt;jee:jndi-lookup id="corePU" jndi-name="java:/exampleDatasource" expected-type="javax.sql.DataSource"/&gt;

&lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
    &lt;property name="persistenceXmlLocation" value="classpath:/META-INF/persistence.xml" /&gt;
    &lt;property name="persistenceUnitName" value="corePU" /&gt;
    &lt;property name="packagesToScan" value="com" /&gt;
&lt;/bean&gt;
</code></pre>

<p>Each entity has <code>@Entity</code> and in <code>persistence.xml</code> following property is set</p>

<p><code>&lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;</code></p>

<pre><code>Hibernate version : 5.1.0.Final
Spring version : 4.1.3.RELEASE
JPA 2.0
WildFly 10
</code></pre>

<p>In <code>applicationContext.xml</code> I have defined an entityManagerFactory bean as follows"</p>

<pre><code>&lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
    &lt;property name="persistenceXmlLocation" value="classpath:/META-INF/persistence.xml" /&gt;
    &lt;property name="persistenceUnitName" value="corePU" /&gt;
    &lt;property name="packagesToScan" value="com" /&gt;
&lt;/bean&gt;
</code></pre>

<p><code>persistence.xml</code> is as follows:</p>

<pre><code>&lt;persistence-unit name="corePU" transaction-type="RESOURCE_LOCAL"&gt;
    &lt;provider&gt;org.hibernate.jpa.HibernatePersistenceProvider&lt;/provider&gt;
    &lt;jta-data-source&gt;java:/exampleDatasource&lt;/jta-data-source&gt;
    &lt;!--&lt;class&gt;com.entity.Address&lt;/class&gt;--&gt;

    &lt;exclude-unlisted-classes&gt;false&lt;/exclude-unlisted-classes&gt;
    &lt;!--&lt;shared-cache-mode&gt;NONE&lt;/shared-cache-mode&gt;--&gt;
    &lt;properties&gt;
        &lt;property name="hibernate.hbm2ddl.auto" value="validate" /&gt;

        &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/&gt;
        &lt;property name="hibernate.show_sql" value="false"/&gt;
        &lt;property name="hibernate.format_sql" value="false"/&gt;
        &lt;property name="hibernate.transaction.jta.platform" value="org.hibernate.service.jta.platform.internal.JBossStandAloneJtaPlatform"/&gt;
        &lt;property name="org.hibernate.envers.audit_table_prefix" value="z_"/&gt;
        &lt;property name="hibernate.cache.use_second_level_cache" value="false" /&gt;
        &lt;property name="hibernate.generate_statistics" value="false"/&gt;
        &lt;property name="hibernate.cache.use_query_cache" value="false"/&gt;
        &lt;property name="hibernate.archive.autodetection" value="class, hbm" /&gt;

    &lt;/properties&gt;
&lt;/persistence-unit&gt;
</code></pre>

<p>Below is the error I am getting:</p>

<pre><code>21:15:47,463 ERROR [stderr] (default task-4) java.lang.IllegalArgumentException: Unknown entity: com.entity.Address
21:15:47,463 ERROR [stderr] (default task-4)    at org.hibernate.jpa.spi.AbstractEntityManagerImpl.persist(AbstractEntityManagerImpl.java:1149)
21:15:47,464 ERROR [stderr] (default task-4)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
21:15:47,464 ERROR [stderr] (default task-4)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
21:15:47,464 ERROR [stderr] (default task-4)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
21:15:47,464 ERROR [stderr] (default task-4)    at java.lang.reflect.Method.invoke(Method.java:498)
21:15:47,464 ERROR [stderr] (default task-4)    at org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.invoke(ExtendedEntityManagerCreator.java:347)
21:15:47,464 ERROR [stderr] (default task-4)    at com.sun.proxy.$Proxy93.persist(Unknown Source)
21:15:47,464 ERROR [stderr] (default task-4)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
21:15:47,464 ERROR [stderr] (default task-4)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
21:15:47,464 ERROR [stderr] (default task-4)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
21:15:47,464 ERROR [stderr] (default task-4)    at java.lang.reflect.Method.invoke(Method.java:498)
21:15:47,465 ERROR [stderr] (default task-4)    at org.springframework.orm.jpa.SharedEntityManagerCreator$SharedEntityManagerInvocationHandler.invoke(SharedEntityManagerCreator.java:298)
21:15:47,465 ERROR [stderr] (default task-4)    at com.sun.proxy.$Proxy50.persist(Unknown Source)
21:15:47,465 ERROR [stderr] (default task-4)    at com.manager.manager.getAddress(manager.java:37)
21:15:47,465 ERROR [stderr] (default task-4)    at com.manager.manager$$FastClassBySpringCGLIB$$e766fff.invoke(&lt;generated&gt;)
21:15:47,465 ERROR [stderr] (default task-4)    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
</code></pre>

<p>How can I use my entities without specifying each entity explicitly in <code>persistence.xml</code> with <code>class</code> tag?</p>