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()));
}
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);
}
}
}
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());
}
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);
}
}
Aggregations