Search in sources :

Example 11 with DeploymentException

use of org.mule.runtime.deployment.model.api.DeploymentException in project mule by mulesoft.

the class ToolingPluginClassLoaderBuilder method build.

@Override
public ToolingArtifactClassLoader build() throws IOException {
    setArtifactDescriptor(new ArtifactDescriptor(TOOLING_EXTENSION_MODEL));
    List<ArtifactPluginDescriptor> resolvedArtifactPluginDescriptors = pluginDependenciesResolver.resolve(emptySet(), ImmutableList.<ArtifactPluginDescriptor>builder().add(artifactPluginDescriptor).build());
    this.addArtifactPluginDescriptors(resolvedArtifactPluginDescriptors.toArray(new ArtifactPluginDescriptor[resolvedArtifactPluginDescriptors.size()]));
    ArtifactClassLoader ownerArtifactClassLoader = super.build();
    ClassLoader parent = ownerArtifactClassLoader.getClassLoader().getParent();
    if (!(parent instanceof RegionClassLoader)) {
        throw new DeploymentException(createStaticMessage(format("The parent of the current owner must be of type '%s' but found '%s'", RegionClassLoader.class.getName(), parent.getClass().getName())));
    }
    final RegionClassLoader regionClassLoader = (RegionClassLoader) parent;
    return new ToolingArtifactClassLoader(regionClassLoader, getPluginArtifactClassLoader(artifactPluginDescriptor, regionClassLoader.getArtifactPluginClassLoaders()));
}
Also used : ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) ArtifactDescriptor(org.mule.runtime.module.artifact.api.descriptor.ArtifactDescriptor) ArtifactPluginDescriptor(org.mule.runtime.deployment.model.api.plugin.ArtifactPluginDescriptor) ArtifactClassLoader(org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader) RegionClassLoader(org.mule.runtime.module.artifact.api.classloader.RegionClassLoader) DisposableClassLoader(org.mule.runtime.module.artifact.api.classloader.DisposableClassLoader) DeploymentException(org.mule.runtime.deployment.model.api.DeploymentException) RegionClassLoader(org.mule.runtime.module.artifact.api.classloader.RegionClassLoader)

Example 12 with DeploymentException

use of org.mule.runtime.deployment.model.api.DeploymentException in project mule by mulesoft.

the class DefaultArchiveDeployer method deployArtifact.

@Override
public void deployArtifact(T artifact, Optional<Properties> deploymentProperties) throws DeploymentException {
    try {
        // add to the list of known artifacts first to avoid deployment loop on failure
        trackArtifact(artifact);
        deploymentListener.onDeploymentStart(artifact.getArtifactName());
        deployer.deploy(artifact);
        artifactArchiveInstaller.createAnchorFile(artifact.getArtifactName());
        deploymentListener.onDeploymentSuccess(artifact.getArtifactName());
        artifactZombieMap.remove(artifact.getArtifactName());
    } catch (Throwable t) {
        // error text has been created by the deployer already
        if (containsType(t, DeploymentStartException.class)) {
            logger.error(miniSplash(format("Failed to deploy artifact '%s', see artifact's log for details", artifact.getArtifactName())));
            logger.error(t.getMessage());
        } else {
            logger.error(miniSplash(format("Failed to deploy artifact '%s', see below", artifact.getArtifactName())), t);
        }
        addZombieApp(artifact);
        deploymentListener.onDeploymentFailure(artifact.getArtifactName(), t);
        if (t instanceof DeploymentException) {
            throw (DeploymentException) t;
        } else {
            throw new DeploymentException(createStaticMessage("Failed to deploy artifact: " + artifact.getArtifactName()), t);
        }
    }
}
Also used : DeploymentStartException(org.mule.runtime.deployment.model.api.DeploymentStartException) DeploymentException(org.mule.runtime.deployment.model.api.DeploymentException)

Example 13 with DeploymentException

use of org.mule.runtime.deployment.model.api.DeploymentException in project mule by mulesoft.

the class DefaultArchiveDeployer method redeploy.

@Override
public void redeploy(T artifact, Optional<Properties> deploymentProperties) throws DeploymentException {
    if (logger.isInfoEnabled()) {
        logger.info(miniSplash(format("Redeploying artifact '%s'", artifact.getArtifactName())));
    }
    deploymentListener.onRedeploymentStart(artifact.getArtifactName());
    deploymentTemplate.preRedeploy(artifact);
    if (!artifactZombieMap.containsKey(artifact.getArtifactName())) {
        deploymentListener.onUndeploymentStart(artifact.getArtifactName());
        try {
            deployer.undeploy(artifact);
            deploymentListener.onUndeploymentSuccess(artifact.getArtifactName());
        } catch (Throwable e) {
            deploymentListener.onUndeploymentFailure(artifact.getArtifactName(), e);
            deploymentListener.onRedeploymentFailure(artifact.getArtifactName(), e);
        }
    }
    deploymentListener.onDeploymentStart(artifact.getArtifactName());
    try {
        artifact = createArtifact(artifact.getLocation(), ofNullable(resolveDeploymentProperties(artifact.getDescriptor().getDataFolderName(), deploymentProperties)));
        trackArtifact(artifact);
        deployer.deploy(artifact);
        artifactArchiveInstaller.createAnchorFile(artifact.getArtifactName());
        deploymentListener.onDeploymentSuccess(artifact.getArtifactName());
        deploymentTemplate.postRedeploy(artifact);
        deploymentListener.onRedeploymentSuccess(artifact.getArtifactName());
    } catch (Throwable t) {
        try {
            logDeploymentFailure(t, artifact.getArtifactName());
            addZombieApp(artifact);
            if (t instanceof DeploymentException) {
                throw (DeploymentException) t;
            }
            String msg = "Failed to deploy artifact: " + artifact.getArtifactName();
            throw new DeploymentException(createStaticMessage(msg), t);
        } finally {
            deploymentListener.onDeploymentFailure(artifact.getArtifactName(), t);
            deploymentListener.onRedeploymentFailure(artifact.getArtifactName(), t);
        }
    }
    artifactZombieMap.remove(artifact.getArtifactName());
}
Also used : DeploymentException(org.mule.runtime.deployment.model.api.DeploymentException)

Example 14 with DeploymentException

use of org.mule.runtime.deployment.model.api.DeploymentException in project mule by mulesoft.

the class DefaultArchiveDeployer method deployPackagedArtifact.

@Override
public T deployPackagedArtifact(String zip, Optional<Properties> deploymentProperties) throws DeploymentException {
    URI uri;
    File artifactZip;
    try {
        final String artifactName = removeEndIgnoreCase(zip, JAR_FILE_SUFFIX);
        artifactZip = new File(artifactDir, zip);
        uri = artifactZip.toURI();
        return deployPackagedArtifact(uri, artifactName, deploymentProperties);
    } catch (DeploymentException e) {
        throw e;
    } catch (Exception e) {
        throw new DeploymentException(createStaticMessage("Failed to deploy from zip: " + zip), e);
    }
}
Also used : DeploymentException(org.mule.runtime.deployment.model.api.DeploymentException) URI(java.net.URI) File(java.io.File) DeploymentStartException(org.mule.runtime.deployment.model.api.DeploymentStartException) DeploymentException(org.mule.runtime.deployment.model.api.DeploymentException) IOException(java.io.IOException)

Aggregations

DeploymentException (org.mule.runtime.deployment.model.api.DeploymentException)14 File (java.io.File)6 IOException (java.io.IOException)4 DeploymentStartException (org.mule.runtime.deployment.model.api.DeploymentStartException)4 URI (java.net.URI)3 ArtifactClassLoader (org.mule.runtime.module.artifact.api.classloader.ArtifactClassLoader)3 RegionClassLoader (org.mule.runtime.module.artifact.api.classloader.RegionClassLoader)3 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2 Optional (java.util.Optional)2 Optional.empty (java.util.Optional.empty)2 BeanPropertyValueEqualsPredicate (org.apache.commons.beanutils.BeanPropertyValueEqualsPredicate)2 CollectionUtils.find (org.apache.commons.collections.CollectionUtils.find)2 SuffixFileFilter (org.apache.commons.io.filefilter.SuffixFileFilter)2 StringUtils.removeEndIgnoreCase (org.apache.commons.lang3.StringUtils.removeEndIgnoreCase)2 I18nMessageFactory.createStaticMessage (org.mule.runtime.api.i18n.I18nMessageFactory.createStaticMessage)2 Application (org.mule.runtime.deployment.model.api.application.Application)2 DeploymentListener (org.mule.runtime.module.deployment.api.DeploymentListener)2 ObservableList (org.mule.runtime.module.deployment.internal.util.ObservableList)2 Logger (org.slf4j.Logger)2