JBIDE-18727 - cannot delete osgi module

How about rewriting it like : 
private int removeModule(IModule[] module, IProgressMonitor monitor) throws CoreException {
  IPrimaryPublishController pc = JBossServerBehaviorUtils.getController(getServer(), IPublishController.SYSTEM_ID, IPrimaryPublishController.class);
  if( ppc != null) {
   return pc.removeModule(module, monitor);
  }
  return IServer.PUBLISH_STATE_UNKNOWN;
}

And in JBossServerBehaviorUtils : 
	public static <T> T getController(IServerAttributes server, String id, Class<T> clazz) throws CoreException {
		IControllableServerBehavior behavior = getControllableBehavior(server);
		if (behavior != null) {
			ISubsystemController controller = behavior.getController(id);
			if (controller != null && clazz.isAssignableFrom(controller.getClass())) {
				return (T)controller;
			}
		}
		return null;
	}