Entity's are not mapped with using "jar-file" in persistence.xml
The structure of my EAR file is as under.
I even tried moving the persistance.xml to MYEAR\METAINF but still could not make hibernate read the entities from the jar files.
My application is packaged in a EAR file like this
MYEAR-
__lib\ | ||
__JPA.jar\ | ||
__METAINF\ | ||
. | __persistence.xml | |
__1.jar | ||
__2.jar | ||
__3.jar | ||
__4.jar | ||
__METAINF\ | ||
__application.xml | ||
__jboss-app.xml | ||
__jboss-deployment-structure.xml | ||
__MY-JAR-1.jar | ||
__MY-JAR-2.jar | ||
__MY-JAR-3.jar | ||
__MY-JAR-4.jar |
contents of persistence.xml is
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0"
>
<persistence-unit name="myPU">
<provider>com.envista.jpa.ENPersistenceProvider</provider>
<!-provider>com.envista.core.persistence.ENPersistenceProvider</provider->
<!-provider>org.hibernate.ejb.HibernatePersistence</provider->
<jta-data-source>java:jboss/datasources/EnvistaOracleDS</jta-data-source>
<jar-file>../MY-JAR-1.jar</jar-file>
<jar-file>../MY-JAR-2.jarr</jar-file>
<jar-file>../MY-JAR-3.jar</jar-file>
<jar-file>../MY-JAR-4.jar</jar-file>
<properties>
<property name="hibernate.archive.autodetection" value="class,hbm" />
<property name="hibernate.dialect" value="com.envista.core.hibernate.dialects.CustomOracle11gDialect" />
<property name="hibernate.max_fetch_depth" value="0" />
<property name="hibernate.default_batch_fetch_size" value="200" />
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.search.default.directory_provider" value="org.hibernate.search.store.FSDirectoryProvider" />
<property name="hibernate.search.default.indexBase" value="./indexes" />
<property name="hibernate.search.autoregister_listeners" value="false" />
<property name="hibernate.search.indexing_strategy" value="event" />
<property name="hibernate.hbm2ddl.auto" value="${envista.db.auto}" />
<property name="hibernate.cache.use_second_level_cache" value="false" />
<property name="hibernate.cache.use_query_cache" value="false" />
<property name="hibernate.cache.provider_class" value="org.jboss.ejb3.entity.TreeCacheProviderHook" />
<property name="hibernate.treecache.mbean.object_name" value="jboss.cache:service=EJB3EntityTreeCache" />
<property name="hibernate.hbm2ddl.auto" value="validate"/> -->
</properties>
</persistence-unit>
I get an error that the Entity is not mapped.
What I see while debugging that when hibernate is scanning the classes to register all the entities marked with @Entity
in class org.hibernate.ejb.packaging.NativeScanner.getClassesInJar(URL jarToScan, Set<Class<? extends Annotation>> annotationsToLookFor)
The value of jarToScan is takes the location where I run JBoss
for e.g. if my JBOSS_INSTALLED directory is C:/Jboss6.0.1Alpha and I run the command from C:/Jboss6.0.1Alpha/bin
C:/Jboss6.0.1Alpha/bin > standalone.bat -c standalone-full.xml
The value of jarToScan = C:/Jboss6.0.1Alpha/bin/content/MYEAR.ear/MY-JAR-1.jar