}
@Deployment
public static Archive<?> deploy() throws Exception {
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, ARCHIVE_NAME + ".ear");
// add required jars as manifest dependencies
ear.addAsManifestResource(new StringAsset("Dependencies: org.hibernate.envers export,org.hibernate\n"), "MANIFEST.MF");
JavaArchive lib = ShrinkWrap.create(JavaArchive.class, "beans.jar");
lib.addClasses(SFSBHibernateEnversSessionFactory.class);
ear.addAsModule(lib);
lib = ShrinkWrap.create(JavaArchive.class, "entities.jar");
lib.addClasses(StudentAudited.class);
lib.addAsResource(new StringAsset(testmapping), "testmapping.hbm.xml");
lib.addAsResource(new StringAsset(hibernate_cfg), "hibernate.cfg.xml");
ear.addAsLibraries(lib);
final WebArchive main = ShrinkWrap.create(WebArchive.class, "main.war");
main.addClasses(Hibernate4NativeAPIEnversTestCase.class);
ear.addAsModule(main);
// add application dependency on H2 JDBC driver, so that the Hibernate classloader (same as app classloader)
// will see the H2 JDBC driver.
// equivalent hack for use of shared Hiberante module, would be to add the H2 dependency directly to the
// shared Hibernate module.
// also add dependency on org.slf4j
ear.addAsManifestResource(new StringAsset("<jboss-deployment-structure>" + " <deployment>" + " <dependencies>"
+ " <module name=\"com.h2database.h2\" />" + " <module name=\"org.slf4j\"/>" + " </dependencies>"
+ " </deployment>" + "</jboss-deployment-structure>"), "jboss-deployment-structure.xml");
return ear;
}