params.target = "server";
ExtendedDeploymentContext deploymentContext = null;
try {
deploymentContext = deployment.getBuilder(_logger, params, report).source(source).build();
deployment.undeploy(name, deploymentContext);
deployment.unregisterAppFromDomainXML(name, "server");
} catch (IOException e) {
_logger.log(Level.SEVERE, "Cannot create context for undeployment ", e);
report.setActionExitCode(ActionReport.ExitCode.FAILURE);
throw new GlassFishException("Cannot create context for undeployment ", e);