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“
###############################################################################################################
src/test/resources/glassfish-resources.xml
###############################################################################################################
Maven dependencies: