use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project tomee by apache.
the class OpenEJBDeployableContainer method start.
@Override
public void start() throws LifecycleException {
try {
initialContext = new InitialContext(properties);
} catch (final NamingException e) {
throw new LifecycleException("can't start the OpenEJB container", e);
}
assembler = SystemInstance.get().getComponent(Assembler.class);
configurationFactory = (ConfigurationFactory) SystemInstance.get().getComponent(OpenEjbConfigurationFactory.class);
if ("true".equalsIgnoreCase(PROPERTIES.getProperty(OpenEjbContainer.OPENEJB_EMBEDDED_REMOTABLE)) && SystemInstance.get().getComponent(WebAppBuilder.class) == null) {
SystemInstance.get().setComponent(WebAppBuilder.class, new LightweightWebAppBuilder());
}
contextProducer.set(initialContext);
containerArchives = ArquillianUtil.toDeploy(properties);
final Closeables globalScopeCloseables = new Closeables();
SystemInstance.get().setComponent(Closeables.class, globalScopeCloseables);
for (final Archive<?> archive : containerArchives) {
try {
quickDeploy(archive, testClass.get(), globalScopeCloseables);
} catch (final DeploymentException e) {
Logger.getLogger(OpenEJBDeployableContainer.class.getName()).log(Level.SEVERE, e.getMessage(), e);
}
}
}
use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project tomee by apache.
the class TomEEContainer method deploy.
@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
try {
final Dump dump = dumpFile(archive);
final File file = dump.getFile();
final String fileName = file.getName();
if (dump.isCreated() && (fileName.endsWith(".war") || fileName.endsWith(".ear"))) {
// extracted folder, TODO: openejb work dir is ignored here
Files.deleteOnExit(new File(file.getParentFile(), fileName.substring(0, fileName.length() - 4)));
}
final AppInfo appInfo;
final String archiveName = archive.getName();
try {
if (dump.isCreated() || !configuration.isSingleDeploymentByArchiveName(archiveName)) {
appInfo = doDeploy(archive, file);
if (appInfo != null) {
moduleIds.put(archiveName, new DeployedApp(appInfo.path, file));
// "i" folder
Files.deleteOnExit(file);
}
} else {
final String path = moduleIds.get(archiveName).path;
AppInfo selected = null;
for (final AppInfo info : getDeployedApps()) {
if (path.equals(info.path)) {
selected = info;
break;
}
}
appInfo = selected;
}
if (appInfo == null) {
LOGGER.severe("appInfo was not found for " + file.getPath() + ", available are: " + apps());
throw new OpenEJBException("can't get appInfo");
}
} catch (final OpenEJBException re) {
// clean up in undeploy needs it
moduleIds.put(archiveName, new DeployedApp(file.getPath(), file));
throw re;
}
if (options.get("tomee.appinfo.output", false)) {
Info.marshal(appInfo);
}
final HTTPContext httpContext = new HTTPContext(configuration.getHost(), configuration.getHttpPort());
addArquillianServlet(archive, appInfo, archiveName, httpContext);
addServlets(httpContext, appInfo);
return new ProtocolMetaData().addContext(httpContext);
} catch (final Exception e) {
throw new DeploymentException("Unable to deploy", e);
}
}
use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project tomee by apache.
the class EmbeddedTomEEContainer method deploy.
@Override
public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentException {
try {
/* don't do it since it should be configurable
final File tempDir = Files.createTempDir();
final File file = new File(tempDir, name);
*/
final String name = archive.getName();
final Dump dump = this.dumpFile(archive);
final File file = dump.getFile();
if (dump.isCreated() || !configuration.isSingleDeploymentByArchiveName(name)) {
ARCHIVES.put(archive, file);
final Thread current = Thread.currentThread();
final ClassLoader loader = current.getContextClassLoader();
// multiple deployments, don't leak a loader
current.setContextClassLoader(ParentClassLoaderFinder.Helper.get());
try {
this.container.deploy(name, file);
} finally {
current.setContextClassLoader(loader);
}
}
final AppInfo info = this.container.getInfo(name);
final String context = this.getArchiveNameWithoutExtension(archive);
final HTTPContext httpContext = new HTTPContext(this.configuration.getHost(), this.configuration.getHttpPort());
httpContext.add(new Servlet("ArquillianServletRunner", "/" + context));
this.addServlets(httpContext, info);
// ensure tests can use request/session scopes even if we don't have a request
startCdiContexts(name);
TestObserver.ClassLoaders classLoaders = this.classLoader.get();
if (classLoaders == null) {
classLoaders = new TestObserver.ClassLoaders();
this.classLoader.set(classLoaders);
}
classLoaders.register(archive.getName(), SystemInstance.get().getComponent(ContainerSystem.class).getAppContext(info.appId).getClassLoader());
return new ProtocolMetaData().addContext(httpContext);
} catch (final Exception e) {
throw new DeploymentException("Unable to deploy", e);
}
}
use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project tomee by apache.
the class OpenEJBDeployableContainer method undeploy.
@Override
public void undeploy(final Archive<?> archive) throws DeploymentException {
final Closeables cl = closeables.get();
if (cl != null) {
try {
cl.close();
} catch (final IOException e) {
// no-op
}
}
// reset classloader for next text
// otherwise if it was closed something can fail
final TestObserver.ClassLoaders classLoaders = classLoader.get();
if (classLoaders != null) {
classLoaders.unregister(archive.getName());
}
final AppContext ctx = appContext.get();
if (ctx == null) {
return;
} else {
// release all references of the previous one - classloaders whatever arquillian Instance impl is etc
appContextProducer.set(NO_APP_CTX);
}
try {
if (!configuration.isSingleDeploymentByArchiveName(archive.getName())) {
assembler.destroyApplication(info.get().path);
}
if (configuration.isStartDefaultScopes() && ctx.getWebBeansContext() != null) {
stopContexts(ctx.getWebBeansContext().getContextsService(), servletContext.get(), session.get());
}
} catch (final Exception e) {
throw new DeploymentException("can't undeploy " + archive.getName(), e);
}
}
use of org.jboss.arquillian.container.spi.client.container.DeploymentException in project camel by apache.
the class ManagedSEDeployableContainer method readJarFilesFromDirectory.
private void readJarFilesFromDirectory() throws DeploymentException {
if (librariesPath == null) {
return;
}
File lib = new File(librariesPath);
if (!lib.exists() || lib.isFile()) {
throw new DeploymentException("Cannot read files from " + librariesPath);
}
File[] dep = lib.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith(".jar");
}
});
classpathDependencies.addAll(Arrays.asList(dep));
}
Aggregations