aspose file tools*
The moose likes JBoss/WildFly and the fly likes InstanceAlreadyExistsException when deploying multiple versions of the same ear Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "InstanceAlreadyExistsException when deploying multiple versions of the same ear" Watch "InstanceAlreadyExistsException when deploying multiple versions of the same ear" New topic
Author

InstanceAlreadyExistsException when deploying multiple versions of the same ear

Dan Seaver
Greenhorn

Joined: Mar 02, 2010
Posts: 8
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


Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

You can ignore the WARN messages. See the comments in this JIRA https://jira.jboss.org/jira/browse/JBAS-6821 for details.


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.


As for the error message, it appears that you are deploying the same datasource in multiple .ear files. Is that right?



[My Blog] [JavaRanch Journal]
Dan Seaver
Greenhorn

Joined: Mar 02, 2010
Posts: 8
Yes, I am deploying the same datasource in both ears.
Dan Seaver
Greenhorn

Joined: Mar 02, 2010
Posts: 8
Jaikiran,
Thanks for the pointer on the warning messages. In JBOSS_HOME/server/< servername>/conf/bootstrap/deployers.xml, I commented out the @JMX annotation for the DeployersImpl bean (second line below) and the warning messages are gone:

<bean name="Deployers" class="org.jboss.deployers.plugins.deployers.DeployersImpl">
<!--<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="jboss.deployment:service=DeployersImpl", exposedInterface=org.jboss.deployers.plugins.deployers.DeployersImplMBean.class, registerDirectly=true)</annotation>-->
<constructor><parameter><inject bean="jboss.kernel:service=KernelController"/></parameter></constructor>
<!-- Accept any implementor of deployer -->
<incallback method="addDeployer"/>
<uncallback method="removeDeployer"/>
<property name="mgtObjectCreator"><inject bean="ManagedObjectCreator"/></property>
</bean>

On a similar issue as the datasource issue, I'm deploying the same MBean in both ears as well. Can these be scoped to each ear as well? Right now I get the following error when the second ear attempts to deploy:

ERROR [AbstractKernelController] Error installing to Create: name=jboss.j2ee:ear=xxx.ear,jar=xxx.jar,name=ApplicationSettings,service=EJB3 state=Configured
java.lang.RuntimeException: Problem registering @Management interface for @Service class xxx.impl.ApplicationSettings
at org.jboss.ejb3.service.ServiceContainer.registerManagementInterface(ServiceContainer.java:794)...

Dan
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10266
    
168

Dan Seaver wrote:
On a similar issue as the datasource issue, I'm deploying the same MBean in both ears as well. Can these be scoped to each ear as well?


The MBeans and the datasources are not scoped per application. The MBeans are deployed to the MBeanServer and registered using the "name" attribute that you specify for the MBean. That has to be unique per server. So you can't have 2 applications deploying the same MBean with the same name.

As for the datasources, JBoss creates MBean out of those datasources and uses the "jndiname" to create the MBean name out of it. Additionally, it also binds the datasource to the JNDI and uses the "jndiname" as the key. As such, you will have to have unique JNDI names for those datasources.
Dan Seaver
Greenhorn

Joined: Mar 02, 2010
Posts: 8
Drat!

Thanks for your insight.

Dan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: InstanceAlreadyExistsException when deploying multiple versions of the same ear