use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project camel by apache.
the class ManagedSEDeployableContainer method deploy.
@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
LOGGER.info("Deploying " + archive.getName());
// First of all clear the list of previously materialized deployments - otherwise the class path would grow indefinitely
materializedFiles.clear();
// Create a new classpath
classpathDependencies.clear();
if (ClassPath.isRepresentedBy(archive)) {
for (Node child : archive.get(ClassPath.ROOT_ARCHIVE_PATH).getChildren()) {
Asset asset = child.getAsset();
if (asset instanceof ArchiveAsset) {
Archive<?> assetArchive = ((ArchiveAsset) asset).getArchive();
if (ClassPathDirectory.isRepresentedBy(assetArchive)) {
materializeDirectory(assetArchive);
} else {
materializeArchive(assetArchive);
}
}
}
} else {
materializeArchive(archive);
}
Properties systemProperties = getSystemProperties(archive);
readJarFilesFromDirectory();
addTestResourcesDirectory(systemProperties);
List<String> processCommand = buildProcessCommand(systemProperties);
logExecutedCommand(processCommand);
// Launch the process
final ProcessBuilder processBuilder = new ProcessBuilder(processCommand);
String path = systemProperties.getProperty("container.user.dir");
if (path != null) {
processBuilder.directory(new File(path));
}
processBuilder.environment().put("JAVA_HOME", new File(System.getProperty(SYSPROP_KEY_JAVA_HOME)).getAbsolutePath());
processBuilder.redirectErrorStream(true);
processBuilder.redirectError(ProcessBuilder.Redirect.INHERIT);
processBuilder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
try {
process = processBuilder.start();
} catch (final IOException e) {
throw new DeploymentException("Could not start process", e);
}
int finalWaitTime = debugModeEnabled ? (3 * waitTime) : waitTime;
// Wait for socket connection
if (!isServerStarted(host, port, finalWaitTime)) {
throw new DeploymentException("Child JVM process failed to start within " + finalWaitTime + " seconds.");
}
if (!isJMXTestRunnerMBeanRegistered(host, port, finalWaitTime)) {
throw new DeploymentException("JMXTestRunnerMBean not registered within " + finalWaitTime + " seconds.");
}
ProtocolMetaData protocolMetaData = new ProtocolMetaData();
protocolMetaData.addContext(new JMXContext(host, port));
return protocolMetaData;
}
use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project camel by apache.
the class ManagedSEDeployableContainer method materializeDirectory.
private void materializeDirectory(Archive<?> archive) throws DeploymentException {
if (archive.getContent().isEmpty()) {
// Do not materialize an empty directory
return;
}
File entryDirectory = new File(TARGET.concat(File.separator).concat(archive.getName()));
try {
if (entryDirectory.exists()) {
// Always delete previous content
FileDeploymentUtils.deleteContent(entryDirectory.toPath());
} else {
if (!entryDirectory.mkdirs()) {
throw new DeploymentException("Could not create class path directory: " + entryDirectory);
}
}
for (Node child : archive.get(ClassPath.ROOT_ARCHIVE_PATH).getChildren()) {
Asset asset = child.getAsset();
if (asset instanceof ClassAsset) {
FileDeploymentUtils.materializeClass(entryDirectory, (ClassAsset) asset);
} else if (asset == null) {
FileDeploymentUtils.materializeSubdirectories(entryDirectory, child);
}
}
} catch (IOException e) {
throw new DeploymentException("Could not materialize class path directory: " + archive.getName(), e);
}
materializedFiles.add(entryDirectory);
}
use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project camel by apache.
the class ManagedSEDeployableContainer method isJMXTestRunnerMBeanRegistered.
private boolean isJMXTestRunnerMBeanRegistered(final String host, final int port, int waitTime) throws DeploymentException {
// Taken from org.jboss.arquillian.container.spi.client.protocol.metadata.JMXContext
final String jmxServiceUrl = "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi";
try (JMXConnector jmxc = JMXConnectorFactory.connect(new JMXServiceURL(jmxServiceUrl), null)) {
final MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
return new Await(waitTime, new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
mbsc.getObjectInstance(new ObjectName(JMXTestRunnerMBean.OBJECT_NAME));
LOGGER.fine("JMXTestRunnerMBean registered with the remote MBean server at: " + jmxServiceUrl);
return true;
}
}).start();
} catch (IOException e) {
throw new DeploymentException("Could not verify JMXTestRunnerMBean registration", e);
}
}
use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project Payara by payara.
the class CommonPayaraManager method deploy.
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
if (archive == null) {
throw new IllegalArgumentException("archive must not be null");
}
final String archiveName = archive.getName();
final ProtocolMetaData protocolMetaData = new ProtocolMetaData();
try {
InputStream deployment = archive.as(ZipExporter.class).exportAsInputStream();
// Build up the POST form to send to Payara
final FormDataMultiPart form = new FormDataMultiPart();
form.bodyPart(new StreamDataBodyPart("id", deployment, archiveName));
deploymentName = createDeploymentName(archiveName);
addDeployFormFields(deploymentName, form);
// Do Deploy the application on the remote Payara
HTTPContext httpContext = payaraClient.doDeploy(deploymentName, form);
protocolMetaData.addContext(httpContext);
} catch (PayaraClientException e) {
throw new DeploymentException("Could not deploy " + archiveName, e);
}
return protocolMetaData;
}
Aggregations