I'd like to use one instance of
JBoss AS (5.1.GA) to run a demo version, qa version, and dev version of our application which is being deployed as an EAR. Because each ear is using the same persistence
unit name, I get the following warnings and error when deploying the second ear:
WARN [AbstractDeploymentContext] Unable to register deployment mbean org.jboss.metadata.jpa.spec.PersistenceUnitMetaData.xxx
javax.management.InstanceAlreadyExistsException: jboss.deployment:id="org.jboss.metadata.jpa.spec.PersistenceUnitMetaData.xxx",type=Component already registered.
WARN [AbstractDeploymentContext] Unable to register deployment mbean jboss.jca:name=xxxDS,service=ManagedConnectionFactory
javax.management.InstanceAlreadyExistsException: jboss.deployment:id="jboss.jca:name=xxxDS,service=ManagedConnectionFactory",type=Component already registered.
WARN [AbstractDeploymentContext] Unable to register deployment mbean jboss.jca:name=xxxDS,service=ManagedConnectionPool
javax.management.InstanceAlreadyExistsException: jboss.deployment:id="jboss.jca:name=xxxDS,service=ManagedConnectionPool",type=Component already registered.
WARN [AbstractDeploymentContext] Unable to register deployment mbean jboss.jca:name=xxxDS,service=LocalTxCM
javax.management.InstanceAlreadyExistsException: jboss.deployment:id="jboss.jca:name=xxxDS,service=LocalTxCM",type=Component already registered.
WARN [AbstractDeploymentContext] Unable to register deployment mbean jboss.jca:name=xxxDS,service=DataSourceBinding
javax.management.InstanceAlreadyExistsException: jboss.deployment:id="jboss.jca:name=xxxDS,service=DataSourceBinding",type=Component already registered.
ERROR [AbstractKernelController] Error installing to Real: name=vfszip:.../deploy/xxx-0.1.0.ear/ state=PreReal mode=Manual requiredState=Real
org.jboss.deployers.spi.DeploymentException: Error deploying: jboss.jca:service=ManagedConnectionFactory,name=xxxDS
vfszip:.../deploy/xxx-0.1.0.ear/ -> org.jboss.deployers.spi.DeploymentException: Error deploying: jboss.jca:service=ManagedConnectionFactory,name=xxxDS
DEPLOYMENTS IN ERROR:
Deployment "vfszip:.../deploy/xxx-0.1.0.ear/" is in error due to the following reason(s): java.lang.IllegalStateException: jboss.jca:name=xxxDS,service=ManagedConnectionFactory is already installed.
At that point, the second ear is undeployed by JBoss.
Shouldn't the persistence units be local to each ear instead of globally defined within the JBoss container?
Is there a fix for this issue?
Is there a different workaround then having to define unique persistence units and changing the code in each ear to refer to the distinct name?
An example:
@PersistenceContext(unitName = "xxx")
private EntityManager em;
I'd have to change this in every session bean to refer to the unique name for the particular ear being deployed.
Any help here would be greatly appreciated.
Dan