Glassfish 3.1.2.2 with multiple deployments
bissaias Aug 25, 2013 4:41 AMHi,
I am trying to deploy two jars in a Glassfish 3.1.2.2 embedded test. Each jar holds a different JPA persistence unit connected to a different Derby database. The creation of the databases and the first deployment are completed successfully, but when the second deployment begins I get the following error message:
SEVERE: Application with name test is already registered. Either specify that redeployment must be forced, or redeploy the application. Or if this is a new deployment, pick a different name.
Subsequently the test fails.
My deployment methods are the following:
@Deployment(name = "joblet1" )
public static JavaArchive deployJoblet1() {
return ShrinkWrap.create(JavaArchive.class, "joblet1-jpa.jar")
.addPackage(Professor.class.getPackage())
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsManifestResource("glassfish/joblet1-persistence.xml", "persistence.xml");
}
@Deployment(name = "joblet2")
public static JavaArchive deployJoblet2() {
return ShrinkWrap.create(JavaArchive.class, "joblet2-jpa.jar")
.addPackage(Professor2.class.getPackage())
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsManifestResource("glassfish/joblet2-persistence.xml", "persistence.xml");
}
My pom looks like below:
<dependencies> <dependency> <groupId>org.jboss.arquillian.container</groupId> <artifactId>arquillian-glassfish-embedded-3.1</artifactId> <version>1.0.0.CR4</version> </dependency> <dependency> <groupId>org.glassfish.main.extras</groupId> <artifactId>glassfish-embedded-web</artifactId> <version>3.1.2.2</version> </dependency> </dependencies>
When I disable one of the two deployments the test completes successfully.
It looks like both deployments are performed under the same name (i.e. test) while I was expecting that the name of the deployments would be used (i.e. joblet1 and joblet2).