Search in sources :

Example 6 with DeployCommandParameters

use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.

the class ModuleInfo method start.

public synchronized void start(DeploymentContext context, ProgressTracker tracker) throws Exception {
    Logger logger = context.getLogger();
    if (started)
        return;
    loaded = true;
    ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
    StructuredDeploymentTracing tracing = StructuredDeploymentTracing.load(context);
    try (DeploymentSpan span = tracing.startSpan(TraceContext.Level.MODULE, getName(), DeploymentTracing.AppStage.START)) {
        Thread.currentThread().setContextClassLoader(context.getClassLoader());
        // registers all deployed items.
        for (EngineRef engine : _getEngineRefs()) {
            if (logger.isLoggable(FINE)) {
                logger.log(FINE, "starting {0}", engine.getContainerInfo().getSniffer().getModuleType());
            }
            try (DeploymentSpan innerSpan = tracing.startSpan(TraceContext.Level.CONTAINER, engine.getContainerInfo().getSniffer().getModuleType(), DeploymentTracing.AppStage.START)) {
                if (!engine.start(context, tracker)) {
                    logger.log(SEVERE, "Module not started {0}", engine.getApplicationContainer().toString());
                    throw new Exception("Module not started " + engine.getApplicationContainer().toString());
                }
            } catch (Exception e) {
                DeployCommandParameters dcp = context.getCommandParameters(DeployCommandParameters.class);
                if (dcp.isSkipDSFailure() && ExceptionUtil.isDSFailure(e)) {
                    logger.log(WARNING, "Resource communication failure exception skipped while invoking " + engine.getApplicationContainer().getClass() + " start method", e);
                } else {
                    logger.log(SEVERE, "Exception while invoking " + engine.getApplicationContainer().getClass() + " start method", e);
                    throw e;
                }
            }
        }
        started = true;
        if (events != null) {
            try (DeploymentSpan innerSpan = tracing.startSpan(DeploymentTracing.AppStage.PROCESS_EVENTS, Deployment.MODULE_STARTED.type())) {
                events.send(new Event<ModuleInfo>(Deployment.MODULE_STARTED, this), false);
            }
        }
    } finally {
        Thread.currentThread().setContextClassLoader(currentClassLoader);
    }
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) StructuredDeploymentTracing(org.glassfish.internal.deployment.analysis.StructuredDeploymentTracing) DeploymentSpan(org.glassfish.internal.deployment.analysis.DeploymentSpan) Logger(java.util.logging.Logger) PropertyVetoException(java.beans.PropertyVetoException)

Example 7 with DeployCommandParameters

use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.

the class ModuleInfo method reload.

public synchronized void reload(DeploymentContext context, ProgressTracker tracker) throws Exception {
    Logger logger = context.getLogger();
    ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
    StructuredDeploymentTracing tracing = StructuredDeploymentTracing.load(context);
    try (DeploymentSpan span = tracing.startSpan(TraceContext.Level.MODULE, getName(), DeploymentTracing.AppStage.START)) {
        Thread.currentThread().setContextClassLoader(context.getClassLoader());
        for (EngineRef engine : _getEngineRefs()) {
            if (logger.isLoggable(FINE)) {
                logger.log(FINE, "Reloading {0}", engine.getContainerInfo().getSniffer().getModuleType());
            }
            try (DeploymentSpan innerSpan = tracing.startSpan(TraceContext.Level.CONTAINER, engine.getContainerInfo().getSniffer().getModuleType(), DeploymentTracing.AppStage.START)) {
                if (!engine.reload(context, tracker)) {
                    logger.log(SEVERE, "Module not reloaded {0}", engine.getApplicationContainer().toString());
                    throw new Exception("Module not reloaded " + engine.getApplicationContainer().toString());
                }
            } catch (Exception e) {
                DeployCommandParameters dcp = context.getCommandParameters(DeployCommandParameters.class);
                if (dcp.isSkipDSFailure() && ExceptionUtil.isDSFailure(e)) {
                    logger.log(WARNING, "Resource communication failure exception skipped while invoking " + engine.getApplicationContainer().getClass() + " start method", e);
                } else {
                    logger.log(SEVERE, "Exception while invoking " + engine.getApplicationContainer().getClass() + " reload method", e);
                    throw e;
                }
            }
        }
    } finally {
        Thread.currentThread().setContextClassLoader(currentClassLoader);
    }
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) StructuredDeploymentTracing(org.glassfish.internal.deployment.analysis.StructuredDeploymentTracing) DeploymentSpan(org.glassfish.internal.deployment.analysis.DeploymentSpan) Logger(java.util.logging.Logger) PropertyVetoException(java.beans.PropertyVetoException)

Example 8 with DeployCommandParameters

use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.

the class ApplicationLoaderService method postConstruct.

/**
 * Starts the application loader service.
 *
 * Look at the list of applications installed in our local repository
 * Get a Deployer capable for each application found
 * Invoke the deployer load() method for each application.
 */
public void postConstruct() {
    assert env != null;
    try {
        logger.fine("Satisfying Optional Packages dependencies...");
        InstalledLibrariesResolver.initializeInstalledLibRegistry(env.getLibPath().getAbsolutePath());
    } catch (Exception e) {
        logger.log(Level.WARNING, KernelLoggerInfo.exceptionOptionalDepend, e);
    }
    DeploymentLifecycleStatsProvider dlsp = new DeploymentLifecycleStatsProvider();
    StatsProviderManager.register("deployment", PluginPoint.SERVER, "deployment/lifecycle", dlsp);
    deploymentTracingEnabled = System.getProperty("org.glassfish.deployment.trace");
    domain = habitat.getService(Domain.class);
    /*
         * Build a map that associates an application with its
         * order in domain.xml.  If the deployment-order attribute
         * is not used for any application, then the applications
         * are loaded in the order they occur in domain.xml.  Also, for
         * applications with the same deployment-order attribute,
         * the applications are loaded in the order they occur in domain.xml.
         * Otherwise, applications are loaded according to the
         * deploynment-order attribute.
         */
    systemApplications = domain.getSystemApplications();
    for (Application systemApp : systemApplications.getApplications()) {
        appOrderInfoMap.put(systemApp.getName(), Integer.valueOf(appOrder++));
    }
    List<Application> standaloneAdapters = applications.getApplicationsWithSnifferType(ServerTags.CONNECTOR, true);
    for (Application standaloneAdapter : standaloneAdapters) {
        appOrderInfoMap.put(standaloneAdapter.getName(), Integer.valueOf(appOrder++));
    }
    List<Application> allApplications = applications.getApplications();
    for (Application app : allApplications) {
        appOrderInfoMap.put(app.getName(), Integer.valueOf(appOrder++));
    }
    for (Application systemApp : systemApplications.getApplications()) {
        // check to see if we need to load up this system application
        if (Boolean.valueOf(systemApp.getDeployProperties().getProperty(ServerTags.LOAD_SYSTEM_APP_ON_STARTUP))) {
            if (deployment.isAppEnabled(systemApp) || loadAppOnDAS(systemApp.getName())) {
                Integer order = appOrderInfoMap.get(systemApp.getName());
                ApplicationOrderInfo info = new ApplicationOrderInfo(systemApp, order);
                DeploymentOrder.addApplicationDeployment(info);
            }
        }
    }
    // load standalone resource adapters first
    for (Application standaloneAdapter : standaloneAdapters) {
        // information is available on DAS
        if (deployment.isAppEnabled(standaloneAdapter) || loadAppOnDAS(standaloneAdapter.getName())) {
            DeploymentOrder.addApplicationDeployment(new ApplicationOrderInfo(standaloneAdapter, appOrderInfoMap.get(standaloneAdapter.getName()).intValue()));
        }
    }
    // then the rest of the applications
    for (Application app : allApplications) {
        if (app.isStandaloneModule() && app.containsSnifferType(ServerTags.CONNECTOR)) {
            continue;
        }
        // information is available on DAS
        if (Boolean.valueOf(app.getEnabled()) || loadAppOnDAS(app.getName())) {
            DeploymentOrder.addApplicationDeployment(new ApplicationOrderInfo(app, appOrderInfoMap.get(app.getName()).intValue()));
        }
    }
    List<Deployment.ApplicationDeployment> appDeployments = new ArrayList<>();
    // process the deployed applications
    Iterator iter = DeploymentOrder.getApplicationDeployments();
    while (iter.hasNext()) {
        Application app = (Application) iter.next();
        ApplicationRef appRef = server.getApplicationRef(app.getName());
        if (appRef != null) {
            // Does the application need to be run on this instance?
            appDeployments.addAll(processApplication(app, appRef));
        }
    }
    // does the user want us to run a particular application
    String defaultParam = env.getStartupContext().getArguments().getProperty("default");
    if (defaultParam != null) {
        initializeRuntimeDependencies();
        File sourceFile;
        if (defaultParam.equals(".")) {
            sourceFile = new File(System.getProperty("user.dir"));
        } else {
            sourceFile = new File(defaultParam);
        }
        if (sourceFile.exists()) {
            sourceFile = sourceFile.getAbsoluteFile();
            ReadableArchive sourceArchive = null;
            try {
                sourceArchive = archiveFactoryProvider.get().openArchive(sourceFile);
                DeployCommandParameters parameters = new DeployCommandParameters(sourceFile);
                parameters.name = sourceFile.getName();
                parameters.enabled = Boolean.TRUE;
                parameters.origin = DeployCommandParameters.Origin.deploy;
                ActionReport report = new HTMLActionReporter();
                if (!sourceFile.isDirectory()) {
                    // ok we need to explode the directory somwhere and remember to delete it on shutdown
                    final File tmpFile = File.createTempFile(sourceFile.getName(), "");
                    final String path = tmpFile.getAbsolutePath();
                    if (!tmpFile.delete()) {
                        logger.log(Level.WARNING, KernelLoggerInfo.cantDeleteTempFile, path);
                    }
                    File tmpDir = new File(path);
                    FileUtils.deleteOnExit(tmpDir);
                    events.register(new org.glassfish.api.event.EventListener() {

                        public void event(Event event) {
                            if (event.is(EventTypes.SERVER_SHUTDOWN)) {
                                if (tmpFile.exists()) {
                                    FileUtils.whack(tmpFile);
                                }
                            }
                        }
                    });
                    if (tmpDir.mkdirs()) {
                        ArchiveHandler handler = deployment.getArchiveHandler(sourceArchive);
                        final String appName = handler.getDefaultApplicationName(sourceArchive);
                        DeploymentContextImpl dummyContext = new DeploymentContextImpl(report, logger, sourceArchive, parameters, env);
                        handler.expand(sourceArchive, archiveFactoryProvider.get().createArchive(tmpDir), dummyContext);
                        sourceArchive = archiveFactoryProvider.get().openArchive(tmpDir);
                        logger.log(Level.INFO, KernelLoggerInfo.sourceNotDirectory, tmpDir.getAbsolutePath());
                        parameters.name = appName;
                    }
                }
                ExtendedDeploymentContext depContext = deployment.getBuilder(logger, parameters, report).source(sourceArchive).build();
                Deployment.ApplicationDeployment appDeployment = deployment.prepare(null, depContext);
                if (appDeployment == null) {
                    logger.log(Level.SEVERE, KernelLoggerInfo.cantFindApplicationInfo, sourceFile.getAbsolutePath());
                } else {
                    appDeployments.add(appDeployment);
                }
            } catch (RuntimeException | IOException e) {
                logger.log(Level.SEVERE, KernelLoggerInfo.deployException, e);
            } finally {
                if (sourceArchive != null) {
                    try {
                        sourceArchive.close();
                    } catch (IOException ioe) {
                    // ignore
                    }
                }
            }
        }
    }
    events.send(new Event<>(Deployment.ALL_APPLICATIONS_LOADED, null), false);
    for (Deployment.ApplicationDeployment depl : appDeployments) {
        deployment.initialize(depl.appInfo, depl.appInfo.getSniffers(), depl.context);
    }
    events.send(new Event<>(Deployment.ALL_APPLICATIONS_PROCESSED, null));
}
Also used : ArchiveHandler(org.glassfish.api.deployment.archive.ArchiveHandler) ActionReport(org.glassfish.api.ActionReport) DeploymentLifecycleStatsProvider(org.glassfish.deployment.monitor.DeploymentLifecycleStatsProvider) IOException(java.io.IOException) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) DeploymentContextImpl(org.glassfish.deployment.common.DeploymentContextImpl) DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) HTMLActionReporter(com.sun.enterprise.admin.report.HTMLActionReporter) Event(org.glassfish.api.event.EventListener.Event) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) File(java.io.File)

Example 9 with DeployCommandParameters

use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.

the class ApplicationLoaderService method loadApplicationForTenants.

private List<Deployment.ApplicationDeployment> loadApplicationForTenants(Application app, ApplicationRef appRef, ActionReport report) {
    if (app.getAppTenants() == null) {
        return Collections.unmodifiableList(Collections.emptyList());
    }
    List<Deployment.ApplicationDeployment> appDeployments = new ArrayList<>();
    for (AppTenant tenant : app.getAppTenants().getAppTenant()) {
        DeployCommandParameters commandParams = app.getDeployParameters(appRef);
        commandParams.contextroot = tenant.getContextRoot();
        commandParams.target = server.getName();
        commandParams.name = DeploymentUtils.getInternalNameForTenant(app.getName(), tenant.getTenant());
        commandParams.enabled = Boolean.TRUE;
        commandParams.origin = DeployCommandParameters.Origin.load;
        ActionReport subReport = report.addSubActionsReport();
        ReadableArchive archive = null;
        try {
            URI uri = new URI(app.getLocation());
            File file = new File(uri);
            if (file.exists()) {
                archive = archiveFactoryProvider.get().openArchive(file);
                ExtendedDeploymentContext deploymentContext = deployment.getBuilder(KernelLoggerInfo.getLogger(), commandParams, subReport).source(archive).build();
                deploymentContext.getAppProps().putAll(app.getDeployProperties());
                deploymentContext.getAppProps().putAll(tenant.getDeployProperties());
                deploymentContext.setModulePropsMap(app.getModulePropertiesMap());
                deploymentContext.setTenant(tenant.getTenant(), app.getName());
                appDeployments.add(deployment.prepare(deployment.getSniffersFromApp(app), deploymentContext));
            } else {
                logger.log(Level.SEVERE, KernelLoggerInfo.notFoundInOriginalLocation, app.getLocation());
            }
        } catch (Throwable e) {
            subReport.setActionExitCode(ActionReport.ExitCode.FAILURE);
            subReport.setMessage(e.getMessage());
            subReport.setFailureCause(e);
        } finally {
            try {
                if (archive != null) {
                    archive.close();
                }
            } catch (IOException e) {
            // ignore
            }
        }
    }
    return Collections.unmodifiableList(appDeployments);
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) IOException(java.io.IOException) ActionReport(org.glassfish.api.ActionReport) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) URI(java.net.URI) File(java.io.File)

Example 10 with DeployCommandParameters

use of org.glassfish.api.deployment.DeployCommandParameters in project Payara by payara.

the class CreateApplicationRefCommand method execute.

/**
 * Entry point from the framework into the command execution
 * @param context context for the command.
 */
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    final Logger logger = context.getLogger();
    // retrieve matched version(s) if exist
    List<String> matchedVersions = null;
    if (enabled) {
        try {
            // warn users that they can use version expressions
            VersioningUtils.checkIdentifier(name);
            matchedVersions = new ArrayList<String>(1);
            matchedVersions.add(name);
        } catch (VersioningWildcardException ex) {
            // a version expression is supplied with enabled == true
            report.setMessage(localStrings.getLocalString("wildcard.not.allowed", "WARNING : version expression are available only with --enabled=false"));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        } catch (VersioningSyntaxException ex) {
            report.setMessage(ex.getLocalizedMessage());
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
        if (!deployment.isRegistered(name)) {
            report.setMessage(localStrings.getLocalString("application.notreg", "Application {0} not registered", name));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
    } else {
        // retrieve matched version(s) if exist
        try {
            matchedVersions = versioningService.getMatchedVersions(name, null);
        } catch (VersioningException e) {
            report.failure(logger, e.getMessage());
            return;
        }
        // this is an unversioned behavior and the given application is not registered
        if (matchedVersions.isEmpty()) {
            report.setMessage(localStrings.getLocalString("ref.not.referenced.target", "Application {0} is not referenced by target {1}", name, target));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
    }
    ActionReport.MessagePart part = report.getTopMessagePart();
    boolean isVersionExpression = VersioningUtils.isVersionExpression(name);
    // for each matched version
    Iterator it = matchedVersions.iterator();
    while (it.hasNext()) {
        String appName = (String) it.next();
        Application applicationInfo = applications.getApplication(appName);
        List<DeploymentGroup> deploymentGroups = domain.getDeploymentGroupsForInstance(target);
        boolean isAppOnDeploymentGroupInstance = false;
        if (deploymentGroups != null && deploymentGroups.isEmpty()) {
            List<Application> applicationsInTarget = domain.getApplicationsInTarget(target);
            List<String> listOfApplications = new ArrayList<>();
            for (Application application : applicationsInTarget) {
                listOfApplications.add(application.getName());
            }
            if (listOfApplications.contains(appName)) {
                isAppOnDeploymentGroupInstance = true;
                break;
            }
        }
        if (!isAppOnDeploymentGroupInstance) {
            ApplicationRef applicationRef = domain.getApplicationRefInTarget(appName, target);
            if (applicationRef != null) {
                // if a versioned name has been provided to the command
                if (isVersionExpression) {
                    ActionReport.MessagePart childPart = part.addChild();
                    childPart.setMessage(localStrings.getLocalString("appref.already.exists", "Application reference {0} already exists in target {1}.", appName, target));
                } else {
                    // returns failure if an untagged name has been provided to the command
                    report.setMessage(localStrings.getLocalString("appref.already.exists", "Application reference {0} already exists in target {1}.", name, target));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    return;
                }
            } else {
                Transaction t = new Transaction();
                if (applicationInfo.isLifecycleModule()) {
                    handleLifecycleModule(context, t);
                    return;
                }
                ReadableArchive archive;
                File file = null;
                DeployCommandParameters commandParams = null;
                Properties contextProps;
                Map<String, Properties> modulePropsMap = null;
                ApplicationConfigInfo savedAppConfig = null;
                try {
                    commandParams = applicationInfo.getDeployParameters(null);
                    commandParams.origin = Origin.create_application_ref;
                    commandParams.command = Command.create_application_ref;
                    commandParams.target = target;
                    commandParams.virtualservers = virtualservers;
                    commandParams.enabled = enabled;
                    if (lbenabled != null) {
                        commandParams.lbenabled = lbenabled;
                    }
                    commandParams.type = applicationInfo.archiveType();
                    contextProps = applicationInfo.getDeployProperties();
                    modulePropsMap = applicationInfo.getModulePropertiesMap();
                    savedAppConfig = new ApplicationConfigInfo(applicationInfo);
                    URI uri = new URI(applicationInfo.getLocation());
                    file = new File(uri);
                    if (!file.exists()) {
                        report.setMessage(localStrings.getLocalString("fnf", "File not found", file.getAbsolutePath()));
                        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                        return;
                    }
                    archive = archiveFactory.openArchive(file);
                } catch (Exception e) {
                    logger.log(Level.SEVERE, "Error opening deployable artifact : " + file.getAbsolutePath(), e);
                    report.setMessage(localStrings.getLocalString("unknownarchiveformat", "Archive format not recognized"));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    return;
                }
                try {
                    final ExtendedDeploymentContext deploymentContext = deployment.getBuilder(logger, commandParams, report).source(archive).build();
                    Properties appProps = deploymentContext.getAppProps();
                    appProps.putAll(contextProps);
                    // relativize the location so it could be set properly in
                    // domain.xml
                    String location = DeploymentUtils.relativizeWithinDomainIfPossible(new URI(applicationInfo.getLocation()));
                    appProps.setProperty(ServerTags.LOCATION, location);
                    // relativize the URI properties so they could store in the
                    // domain.xml properly on the instances
                    String appLocation = appProps.getProperty(Application.APP_LOCATION_PROP_NAME);
                    appProps.setProperty(Application.APP_LOCATION_PROP_NAME, DeploymentUtils.relativizeWithinDomainIfPossible(new URI(appLocation)));
                    String planLocation = appProps.getProperty(Application.DEPLOYMENT_PLAN_LOCATION_PROP_NAME);
                    if (planLocation != null) {
                        appProps.setProperty(Application.DEPLOYMENT_PLAN_LOCATION_PROP_NAME, DeploymentUtils.relativizeWithinDomainIfPossible(new URI(planLocation)));
                    }
                    String altDDLocation = appProps.getProperty(Application.ALT_DD_LOCATION_PROP_NAME);
                    if (altDDLocation != null) {
                        appProps.setProperty(Application.ALT_DD_LOCATION_PROP_NAME, DeploymentUtils.relativizeWithinDomainIfPossible(new URI(altDDLocation)));
                    }
                    String runtimeAltDDLocation = appProps.getProperty(Application.RUNTIME_ALT_DD_LOCATION_PROP_NAME);
                    if (runtimeAltDDLocation != null) {
                        appProps.setProperty(Application.RUNTIME_ALT_DD_LOCATION_PROP_NAME, DeploymentUtils.relativizeWithinDomainIfPossible(new URI(runtimeAltDDLocation)));
                    }
                    savedAppConfig.store(appProps);
                    if (modulePropsMap != null) {
                        deploymentContext.setModulePropsMap(modulePropsMap);
                    }
                    if (enabled) {
                        versioningService.handleDisable(appName, target, deploymentContext.getActionReport(), context.getSubject());
                    }
                    if (domain.isCurrentInstanceMatchingTarget(target, appName, server.getName(), null)) {
                        deployment.deploy(deployment.getSniffersFromApp(applicationInfo), deploymentContext);
                    } else {
                        // send the APPLICATION_PREPARED event for DAS
                        events.send(new Event<DeploymentContext>(Deployment.APPLICATION_PREPARED, deploymentContext), false);
                    }
                    final List<String> targets = new ArrayList<String>(Arrays.asList(commandParams.target.split(",")));
                    List<String> deploymentTarget = new ArrayList<>();
                    // If targets contains Deployment Group, check if the application is already deployed to instances in it.
                    for (String target : targets) {
                        if (isDeploymentGroup(target)) {
                            List<Server> instances = domain.getDeploymentGroupNamed(target).getInstances();
                            for (Server instance : instances) {
                                List<Application> applications = domain.getApplicationsInTarget(instance.getName());
                                List<String> listOfApplications = new ArrayList<>();
                                for (Application application : applications) {
                                    listOfApplications.add(application.getName());
                                }
                                if (!listOfApplications.contains(appName)) {
                                    deploymentTarget.add(instance.getName());
                                }
                            }
                        }
                    }
                    if (report.getActionExitCode().equals(ActionReport.ExitCode.SUCCESS)) {
                        try {
                            deployment.registerAppInDomainXML(null, deploymentContext, t, true);
                        } catch (TransactionFailure e) {
                            logger.warning("failed to create application ref for " + appName);
                        }
                    }
                    // if the target is DAS, we do not need to do anything more
                    if (!isVersionExpression && DeploymentUtils.isDASTarget(target)) {
                        return;
                    }
                    final ParameterMap paramMap = deployment.prepareInstanceDeployParamMap(deploymentContext);
                    if (!deploymentTarget.isEmpty()) {
                        replicateCommand(deploymentTarget, context, paramMap);
                    } else {
                        replicateCommand(targets, context, paramMap);
                    }
                } catch (Exception e) {
                    logger.log(Level.SEVERE, "Error during creating application ref ", e);
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                } finally {
                    try {
                        archive.close();
                    } catch (IOException e) {
                        logger.log(Level.INFO, "Error while closing deployable artifact : " + file.getAbsolutePath(), e);
                    }
                }
            }
        }
    }
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) VersioningWildcardException(org.glassfish.deployment.versioning.VersioningWildcardException) ArrayList(java.util.ArrayList) ActionReport(org.glassfish.api.ActionReport) Logger(java.util.logging.Logger) DeploymentProperties(org.glassfish.deployment.common.DeploymentProperties) Properties(java.util.Properties) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) URI(java.net.URI) Iterator(java.util.Iterator) VersioningException(org.glassfish.deployment.versioning.VersioningException) VersioningSyntaxException(org.glassfish.deployment.versioning.VersioningSyntaxException) ParameterMap(org.glassfish.api.admin.ParameterMap) IOException(java.io.IOException) VersioningException(org.glassfish.deployment.versioning.VersioningException) VersioningWildcardException(org.glassfish.deployment.versioning.VersioningWildcardException) VersioningSyntaxException(org.glassfish.deployment.versioning.VersioningSyntaxException) IOException(java.io.IOException) DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) DeploymentContext(org.glassfish.api.deployment.DeploymentContext) ExtendedDeploymentContext(org.glassfish.internal.deployment.ExtendedDeploymentContext) Transaction(org.jvnet.hk2.config.Transaction) ApplicationConfigInfo(org.glassfish.deployment.common.ApplicationConfigInfo) ReadableArchive(org.glassfish.api.deployment.archive.ReadableArchive) File(java.io.File) DeploymentGroup(fish.payara.enterprise.config.serverbeans.DeploymentGroup)

Aggregations

DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)69 IOException (java.io.IOException)25 File (java.io.File)24 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)24 ActionReport (org.glassfish.api.ActionReport)23 DeploymentContext (org.glassfish.api.deployment.DeploymentContext)16 Application (com.sun.enterprise.deployment.Application)14 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)13 DeploymentProperties (org.glassfish.deployment.common.DeploymentProperties)13 Logger (java.util.logging.Logger)12 Properties (java.util.Properties)10 DeploymentContextImpl (org.glassfish.deployment.common.DeploymentContextImpl)10 DeploymentException (org.glassfish.deployment.common.DeploymentException)10 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)10 ArchiveHandler (org.glassfish.api.deployment.archive.ArchiveHandler)9 VersioningSyntaxException (org.glassfish.deployment.versioning.VersioningSyntaxException)9 Deployment (org.glassfish.internal.deployment.Deployment)9 PropertyVetoException (java.beans.PropertyVetoException)8 URI (java.net.URI)8 UndeployCommandParameters (org.glassfish.api.deployment.UndeployCommandParameters)8