Search in sources :

Example 21 with DeploymentException

use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.

the class SecurityDeployer method commitPolicy.

/**
 * puts Web Bundle Policy In Service, repeats translation is Descriptor indicate policy was changed by ContextListener.
 *
 * @param webBD
 * @throws DeploymentException
 */
private void commitPolicy(WebBundleDescriptor webBD) throws DeploymentException {
    try {
        if (webBD != null) {
            if (webBD.isPolicyModified()) {
                // redo policy translation for web module
                loadPolicy(webBD, true);
            }
            String cid = SecurityUtil.getContextID(webBD);
            websecurityProbeProvider.policyCreationStartedEvent(cid);
            SecurityUtil.generatePolicyFile(cid);
            websecurityProbeProvider.policyCreationEndedEvent(cid);
            websecurityProbeProvider.policyCreationEvent(cid);
        }
    } catch (Exception se) {
        String msg = "Error in generating security policy for " + webBD.getModuleDescriptor().getModuleName();
        throw new DeploymentException(msg, se);
    }
}
Also used : DeploymentException(org.glassfish.deployment.common.DeploymentException) IASSecurityException(com.sun.enterprise.security.util.IASSecurityException) DeploymentException(org.glassfish.deployment.common.DeploymentException)

Example 22 with DeploymentException

use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.

the class SecurityDeployer method linkPolicies.

/**
 * Links the policy contexts of the application
 *
 * @param app
 * @param webs
 */
private void linkPolicies(Application app, Collection<WebBundleDescriptor> webs) throws DeploymentException {
    try {
        String linkName = null;
        boolean lastInService = false;
        for (WebBundleDescriptor wbd : webs) {
            String name = SecurityUtil.getContextID(wbd);
            lastInService = SecurityUtil.linkPolicyFile(name, linkName, lastInService);
            linkName = name;
        }
        // reset link name
        linkName = null;
        Set<EjbBundleDescriptor> ejbs = app.getBundleDescriptors(EjbBundleDescriptor.class);
        for (EjbBundleDescriptor ejbd : ejbs) {
            String name = SecurityUtil.getContextID(ejbd);
            lastInService = SecurityUtil.linkPolicyFile(name, linkName, lastInService);
            linkName = name;
        }
    // extra commit (see above)
    } catch (IASSecurityException se) {
        String msg = "Error in linking security policy for " + app.getRegistrationName();
        throw new DeploymentException(msg, se);
    }
}
Also used : EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) WebBundleDescriptor(com.sun.enterprise.deployment.WebBundleDescriptor) DeploymentException(org.glassfish.deployment.common.DeploymentException) IASSecurityException(com.sun.enterprise.security.util.IASSecurityException)

Example 23 with DeploymentException

use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.

the class ResourcesDeployer method processResources.

private void processResources(DeploymentContext dc, DeployCommandParameters deployParams) {
    try {
        if (deployParams.origin == OpsParams.Origin.deploy || deployParams.origin == OpsParams.Origin.deploy_instance) /*|| (deployParams.origin == OpsParams.Origin.create_application_ref && env.isInstance())*/
        {
            Properties properties = deployParams.properties;
            if (properties != null) {
                // handle if "preserveAppScopedResources" property is set (during deploy --force=true or redeploy)
                String preserve = properties.getProperty(DeploymentProperties.PRESERVE_APP_SCOPED_RESOURCES);
                if (preserve != null && Boolean.valueOf(preserve)) {
                    Boolean redeploy = false;
                    redeploy = deployParams.force;
                    if (redeploy) {
                        String appName = getAppNameFromDeployCmdParams(dc);
                        Map<String, Resources> allResources = ResourcesRegistry.remove(appName);
                        Application oldApp = preservedApps.remove(appName);
                        if (allResources != null && oldApp != null) {
                            Application application = dc.getTransientAppMetaData(ServerTags.APPLICATION, Application.class);
                            validatePreservedResources(allResources, oldApp, application);
                            retainResourceConfig(dc, allResources);
                        }
                        return;
                    }
                }
            }
            Application app = dc.getTransientAppMetaData(ServerTags.APPLICATION, Application.class);
            String applicationName = getAppNameFromDeployCmdParams(dc);
            if (app != null) {
                // application is stored in transient meta data only during deployment.
                processArchive(dc);
                createResources(dc, false, true);
                createResources(dc, true, false);
                deployResources(applicationName, false);
            } else {
                // application config is already present. Use the same.
                deployResourcesFromConfiguration(applicationName, false);
                populateResourceConfigInAppInfo(dc);
            }
        } else if (deployParams.origin == OpsParams.Origin.load) {
            // during load event (ie., app/app-ref enable or server start, resource configuration
            // is present in domain.xml. Use the configuration.
            populateResourceConfigInAppInfo(dc);
        }
    } catch (Exception e) {
        // in the event notification infrastructure
        if (_logger.isLoggable(Level.FINEST)) {
            _logger.log(Level.FINEST, "Exception while processing archive of application" + " [ " + getAppNameFromDeployCmdParams(dc) + " ] for resources definitions : " + e.getCause());
        }
        throw new DeploymentException(e);
    }
}
Also used : DeploymentException(org.glassfish.deployment.common.DeploymentException) DeploymentProperties(org.glassfish.deployment.common.DeploymentProperties) ResourceException(javax.resource.ResourceException) IOException(java.io.IOException) DeploymentException(org.glassfish.deployment.common.DeploymentException) ResourceConflictException(org.glassfish.resourcebase.resources.api.ResourceConflictException)

Example 24 with DeploymentException

use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.

the class ResourcesDeployer method getResources.

/**
 * Retrieve connector and non-connector resources from the archive.
 *
 * @param archive Archieve from which the resources to be retrieved.
 * @param appName Name of the application
 * @param connectorResources Connector resources will be added to this list.
 * @param nonConnectorResources Non connector resources will be added to this list.
 * @param resourceXmlParsers Resource xml parsers corresponding to both connector and non connector resources will be stored in this.
 */
public void getResources(ReadableArchive archive, String appName, List<org.glassfish.resources.api.Resource> connectorResources, List<org.glassfish.resources.api.Resource> nonConnectorResources, Map<org.glassfish.resources.api.Resource, ResourcesXMLParser> resourceXmlParsers) {
    try {
        if (ResourceUtil.hasResourcesXML(archive, locator)) {
            Map<String, Map<String, List>> appScopedResources = new HashMap<String, Map<String, List>>();
            Map<String, String> fileNames = new HashMap<String, String>();
            // using appName as it is possible that "deploy --name=APPNAME" will
            // be different than the archive name.
            retrieveAllResourcesXMLs(fileNames, archive, appName);
            for (Map.Entry<String, String> entry : fileNames.entrySet()) {
                String moduleName = entry.getKey();
                String fileName = entry.getValue();
                debug("GlassFish Resources XML : " + fileName);
                moduleName = org.glassfish.resourcebase.resources.util.ResourceUtil.getActualModuleNameWithExtension(moduleName);
                String scope;
                if (appName.equals(moduleName)) {
                    scope = JAVA_APP_SCOPE_PREFIX;
                } else {
                    scope = JAVA_MODULE_SCOPE_PREFIX;
                }
                File file = new File(fileName);
                ResourcesXMLParser parser = new ResourcesXMLParser(file, scope);
                validateResourcesXML(file, parser);
                List<org.glassfish.resources.api.Resource> resources = parser.getResourcesList();
                if (nonConnectorResources != null) {
                    nonConnectorResources.addAll(ResourcesXMLParser.getNonConnectorResourcesList(resources, false, true));
                }
                if (connectorResources != null) {
                    connectorResources.addAll(ResourcesXMLParser.getConnectorResourcesList(resources, false, true));
                }
                if (resourceXmlParsers != null) {
                    for (org.glassfish.resources.api.Resource res : resources) {
                        resourceXmlParsers.put(res, parser);
                    }
                }
            }
        }
    } catch (Exception e) {
        // in the event notification infrastructure
        throw new DeploymentException("Failue while processing glassfish-resources.xml(s) in the archive ", e);
    }
}
Also used : ResourcesXMLParser(org.glassfish.resources.admin.cli.ResourcesXMLParser) Resource(com.sun.enterprise.config.serverbeans.Resource) Resource(org.glassfish.resources.api.Resource) ResourceException(javax.resource.ResourceException) IOException(java.io.IOException) DeploymentException(org.glassfish.deployment.common.DeploymentException) ResourceConflictException(org.glassfish.resourcebase.resources.api.ResourceConflictException) Resource(org.glassfish.resources.api.Resource) DeploymentException(org.glassfish.deployment.common.DeploymentException) org.glassfish.resources.api(org.glassfish.resources.api) File(java.io.File)

Example 25 with DeploymentException

use of org.glassfish.deployment.common.DeploymentException in project Payara by payara.

the class EjbDeployer method generateArtifacts.

/**
 * Use this method to generate any ejb-related artifacts for the module
 */
@Override
protected void generateArtifacts(DeploymentContext dc) throws DeploymentException {
    OpsParams params = dc.getCommandParameters(OpsParams.class);
    if (!(params.origin.isDeploy() && isDas())) {
        // Generate artifacts only when being deployed on DAS
        return;
    }
    EjbBundleDescriptorImpl bundle = dc.getModuleMetaData(EjbBundleDescriptorImpl.class);
    DeployCommandParameters dcp = dc.getCommandParameters(DeployCommandParameters.class);
    boolean generateRmicStubs = dcp.generatermistubs;
    dc.addTransientAppMetaData(CMPDeployer.MODULE_CLASSPATH, getModuleClassPath(dc));
    if (generateRmicStubs) {
        StaticRmiStubGenerator staticStubGenerator = new StaticRmiStubGenerator(habitat);
        try {
            staticStubGenerator.ejbc(dc);
        } catch (Exception e) {
            throw new DeploymentException("Static RMI-IIOP Stub Generation exception for " + dc.getSourceDir(), e);
        }
    }
    if (bundle == null || !bundle.containsCMPEntity()) {
        // bundle WAS null in a war file where we do not support CMPs
        return;
    }
    initCMPDeployer();
    if (cmpDeployer == null) {
        throw new DeploymentException("No CMP Deployer is available to deploy this module");
    }
    cmpDeployer.deploy(dc);
}
Also used : DeployCommandParameters(org.glassfish.api.deployment.DeployCommandParameters) OpsParams(org.glassfish.api.deployment.OpsParams) DeploymentException(org.glassfish.deployment.common.DeploymentException) StaticRmiStubGenerator(com.sun.ejb.codegen.StaticRmiStubGenerator) DeploymentException(org.glassfish.deployment.common.DeploymentException) IASSecurityException(com.sun.enterprise.security.util.IASSecurityException) EjbBundleDescriptorImpl(org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl)

Aggregations

DeploymentException (org.glassfish.deployment.common.DeploymentException)30 IASSecurityException (com.sun.enterprise.security.util.IASSecurityException)8 IOException (java.io.IOException)6 Application (com.sun.enterprise.deployment.Application)4 File (java.io.File)4 ResourceException (javax.resource.ResourceException)4 ResourceConflictException (org.glassfish.resourcebase.resources.api.ResourceConflictException)4 Iterator (java.util.Iterator)3 DeployCommandParameters (org.glassfish.api.deployment.DeployCommandParameters)3 Resource (com.sun.enterprise.config.serverbeans.Resource)2 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)2 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)2 ArrayList (java.util.ArrayList)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 OpsParams (org.glassfish.api.deployment.OpsParams)2 DeploymentProperties (org.glassfish.deployment.common.DeploymentProperties)2 VersioningSyntaxException (org.glassfish.deployment.versioning.VersioningSyntaxException)2 SAXException (org.xml.sax.SAXException)2 SAXParseException (org.xml.sax.SAXParseException)2 ServiceInterfaceGenerator (com.sun.ejb.codegen.ServiceInterfaceGenerator)1