private void undeploy(String symbolicName) throws DeploymentException { BundleHandle handle = deployedBundles.remove(symbolicName); if (handle != null) { String bundleState = null; try { long bundleId = handle.getBundleId(); CompositeData bundleType = bundleStateMBean.getBundle(bundleId); if (bundleType != null) { bundleState = (String) bundleType.get(BundleStateMBean.STATE); } } catch (IOException e) { // ignore non-existent bundle return; } if (bundleState != null && !bundleState.equals(BundleStateMBean.UNINSTALLED)) { try { long bundleId = handle.getBundleId(); frameworkMBean.uninstallBundle(bundleId); } catch (IOException ex) { logger.error("Cannot undeploy: " + symbolicName, ex); } } } }