Set up a embedded Payara 5 for Arquillian tests with DB2 z/OS drivers 

Despite a lot of tutorials on using embedded Payara with Arquillian, I struggled a while to get the container running. Here are the steps


Code for configuring and deploying the embedded container

@Deployment public static Archive createDeployment() throws IOException {
File[] files = Maven.configureResolver().withMavenCentralRepo(false).loadPomFromFile("pom.xml").resolve("com.ibm:db2jcc4:version1234", "com.ibm:db2jcc_license_cisuz:version1234").withTransitivity().asFile();
final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war").addPackages(true, "my.org.backend").addPackages(true, "my.org.exceptions").addAsResource("persistence.xml", "META-INF/persistence.xml").addAsLibraries(files); // add all xml required for the queries
Files.walk(Paths.get("src/main/resources/META-INF")).forEach(file - >{
if (file.toFile().isFile() && !file.getFileName().toString().equalsIgnoreCase("MANIFEST.MF") && !file.getFileName().toString().equalsIgnoreCase("persistence.xml")) {
final String fileName = file.toAbsolutePath().toString();
final int start = fileName.indexOf("META-INF");
final String resource = fileName.substring(start - 1);
war.addAsResource(file.toFile(), resource);
}
});
return war;
}


Mind to put the arquillian.xml under „src/test/resources“

Maven dependencies:
org.jboss.arquillian.junit arquillian-junit-container 1.4.1.Final test
org.jboss.shrinkwrap.resolver shrinkwrap-resolver-impl-maven 2.2.6 test
junit junit 4.12 test
fish.payara.arquillian arquillian-payara-server-4-embedded 1.0.Beta3 test
fish.payara.extraspayara-embedded-all5.181test