final String baseUrl = "http://" + configuration.getHost() + ":" + httpPort + "/tomee/installer";
assert installer != null;
installer.addTomEEAdminConfInTomcatUsers(true);
final RemoteServer tmpContainer = new RemoteServer();
tmpContainer.setPortStartup(httpPort);
tmpContainer.start();
final URL url = new URL(baseUrl);
logger.info("Calling TomEE Installer Servlet on " + url);
for (int i = 0; i < 3; i++) {
final URLConnection uc = url.openConnection();
// dG9tZWU6dG9tZWU= --> Base64 of tomee:tomee
final String authorizationString = "Basic dG9tZWU6dG9tZWU=";
uc.setRequestProperty("Authorization", authorizationString);
try {
final InputStream is = uc.getInputStream();
org.apache.openejb.loader.IO.slurp(is);
is.close();
break;
} catch (final Exception e) {
logger.warning(e.getMessage());
Thread.sleep(1000);
}
}
tmpContainer.stop();
tmpContainer.getServer().waitFor();
}
container = new RemoteServer();
container.setPortStartup(httpPort);
container.start(Arrays.asList("-Dorg.apache.openejb.servlet.filters=" + ArquillianFilterRunner.class.getName() + "=" + ServletMethodExecutor.ARQUILLIAN_SERVLET_MAPPING), "start", true);
container.killOnExit();
} catch (final Exception e) {
throw new LifecycleException("Unable to start remote container", e);