// Now, search the MBean of this context
ObjectName contextObjectName = null;
try {
contextObjectName = new ObjectName(buildObjectName(warDeployable));
} catch (MalformedObjectNameException e) {
throw new DeployerException("Cannot get the ObjectName for the WAR deployable '" + warDeployable + "'.", e);
} catch (NullPointerException e) {
throw new DeployerException("Cannot get the ObjectName for the WAR deployable '" + warDeployable + "'.", e);
}
// Now, search if the MBean of this context is present
try {
if (!MBeanServerHelper.getMBeanServerServer().isRegistered(contextObjectName)) {
throw new DeployerException("There is no MBean with the ObjectName '" + contextObjectName
+ "' in the MBean Server for the WAR deployable '" + warDeployable + "'.");
}
} catch (JMXRemoteException e) {
throw new DeployerException("Cannot check if the MBean with the ObjectName '" + contextObjectName
+ "'is registered in the MBean Server for the WAR deployable '" + warDeployable + "'.");
}
// Undeploy
try {
MBeanServerHelper.getMBeanServerServer().invoke(contextObjectName, DESTROY_OPERATION, null, null);
} catch (InstanceNotFoundException e) {
throw new DeployerException("Cannot remove the context '" + contextRoot + "' of the war deployable '"
+ warDeployable + "'.", e);
} catch (MBeanException e) {
throw new DeployerException("Cannot remove the context '" + contextRoot + "' of the war deployable '"
+ warDeployable + "'.", e);
} catch (ReflectionException e) {
throw new DeployerException("Cannot remove the context '" + contextRoot + "' of the war deployable '"
+ warDeployable + "'.", e);
} catch (JMXRemoteException e) {
throw new DeployerException("Cannot remove the context '" + contextRoot + "' of the war deployable '"
+ warDeployable + "'.", e);
}
logger.info("The context ''{0}'' of the War ''{1}'' has been undeployed", contextRoot, warDeployable);
}