I’m doing a lot of work in JBoss, and one of the bugs I’ve run into is that if an applications initial deployment fails, JBoss refuses to un-deploy it. It throws this error when you try to redeploy the app (in this case, the app is called ‘app1’ and is deployed as an EAR file) :
23:19:23,054 ERROR [MainDeployer] Could not initialise deployment: file:/home/dbs/jboss/jboss-4.0.1sp1/server/default/deploy/app1.ear
org.jboss.deployment.DeploymentException: Error in accessing application metadata: ; - nested throwable: (javax.management.InstanceAlreadyExistsException: jboss.j2ee:service=EARDeployment,url='app1.ear' already registered.)
Sometimes restarting JBoss appserver from scratch will fix it, but only if you’ve remembered to delete the .ear file before restart.
JBoss comes with a great little tool called ‘twiddle’. It sends commands via JMX right into the appserver. You can force an app to unregister right from the command line:
twiddle.sh unregister jboss.j2ee:service=EARDeployment,url='app1.ear'