Is it possible to make Hibernate scan the Arquillian Archive for a JPA library?
When I run the unit test i see:
DEBUG - Processing PersistenceUnitInfo [
name: ubcRegiDomain
persistence provider classname: org.hibernate.ejb.HibernatePersistence
classloader: org.apache.openejb.arquillian.openejb.SWClassLoader@2be95d31
Temporary classloader: org.apache.openejb.core.TempClassLoader@4cb702ce
excludeUnlistedClasses: false
JTA datasource: org.apache.openejb.resource.jdbc.dbcp.BasicManagedDataSource@2e73d5eb
Non JTA datasource: org.apache.openejb.resource.jdbc.dbcp.BasicDataSource@7b6c6e70
Transaction type: JTA
PU root URL: file:/W:/workspace-arquillian/FJJ lib ubc-test-arquillian-openejb/target/test-classes/
Shared Cache Mode: UNSPECIFIED
Validation Mode: AUTO
Jar files URLs []
Managed classes names []
Mapping files names []
Properties [
hibernate.id.new_generator_mappings: true
hibernate.dialect: org.hibernate.dialect.DerbyTenSevenDialect
hibernate.show_sql: false
hibernate.hbm2ddl.import_files:
hibernate.hbm2ddl.auto: create-drop
hibernate.format_sql: true
hibernate.transaction.jta.platform: org.apache.openejb.hibernate.OpenEJBJtaPlatform]
DEBUG - Detect class: true; detect hbm: true
DEBUG - Detect class: true; detect hbm: true
DEBUG - Searching mapped entities in jar/par: file:/W:/workspace-arquillian/FJJ lib ubc-test-arquillian-openejb/target/test-classes/
The archive is created thus:
final File[] jpafiles = mavenResolver.resolve("ca.ubc.sis:ubc-regiJPA").withoutTransitivity().as(File.class);
final WebArchive archive = ShrinkWrap.create(WebArchive.class, "test.war") //
.addClasses(ArquillianDerbyTest.class, ArquillianDerbyTestInfo.class, DatabaseType.class) //
.addAsLibraries(jpafiles ) //
.addAsWebInfResource(new StringAsset(resourceString), "resources.xml") //
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") //
.addAsWebInfResource("META-INF/" + databaseType + "-persistence.xml", "persistence.xml");
Hibernate obviously knows about the archive but it seems to insist to scan the actual file system for entities.
I kludged around it by exploding the jarFiles into the test-classes directory
final File destinationDir = new File("target/test-classes");
for (final File file : jpafiles) {
final JavaArchive javaArchive = ShrinkWrap.createFromZipFile(JavaArchive.class, file);
javaArchive.as(ExplodedExporter.class).exportExploded(destinationDir, "");
}
Any thoughts?
Thanks
George