Search in sources :

Example 11 with DeploymentException

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);
        }
    }
}
Also used : LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) LightweightWebAppBuilder(org.apache.openejb.web.LightweightWebAppBuilder) NamingException(javax.naming.NamingException) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) Assembler(org.apache.openejb.assembler.classic.Assembler) InitialContext(javax.naming.InitialContext) LocalInitialContext(org.apache.openejb.core.LocalInitialContext)

Example 12 with DeploymentException

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);
    }
}
Also used : OpenEJBException(org.apache.openejb.OpenEJBException) HTTPContext(org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) ProtocolMetaData(org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData) File(java.io.File) NamingException(javax.naming.NamingException) UndeployException(org.apache.openejb.UndeployException) LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) OpenEJBException(org.apache.openejb.OpenEJBException) IOException(java.io.IOException) NoSuchApplicationException(org.apache.openejb.NoSuchApplicationException) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) WebAppInfo(org.apache.openejb.assembler.classic.WebAppInfo) AppInfo(org.apache.openejb.assembler.classic.AppInfo)

Example 13 with DeploymentException

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);
    }
}
Also used : ContainerSystem(org.apache.openejb.spi.ContainerSystem) HTTPContext(org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext) TestObserver(org.apache.openejb.arquillian.common.TestObserver) LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) AppInfo(org.apache.openejb.assembler.classic.AppInfo) Servlet(org.jboss.arquillian.container.spi.client.protocol.metadata.Servlet) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) ProtocolMetaData(org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData) File(java.io.File)

Example 14 with DeploymentException

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);
    }
}
Also used : AppContext(org.apache.openejb.AppContext) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) IOException(java.io.IOException) TestObserver(org.apache.openejb.arquillian.common.TestObserver) NamingException(javax.naming.NamingException) LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) IOException(java.io.IOException) OpenEJBRuntimeException(org.apache.openejb.OpenEJBRuntimeException) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException)

Example 15 with DeploymentException

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));
}
Also used : FilenameFilter(java.io.FilenameFilter) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) File(java.io.File)

Aggregations

DeploymentException (org.jboss.arquillian.container.spi.client.container.DeploymentException)19 File (java.io.File)10 IOException (java.io.IOException)10 LifecycleException (org.jboss.arquillian.container.spi.client.container.LifecycleException)9 NamingException (javax.naming.NamingException)7 ProtocolMetaData (org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData)7 HTTPContext (org.jboss.arquillian.container.spi.client.protocol.metadata.HTTPContext)6 InputStream (java.io.InputStream)4 Node (org.jboss.shrinkwrap.api.Node)4 OpenEJBRuntimeException (org.apache.openejb.OpenEJBRuntimeException)3 TestObserver (org.apache.openejb.arquillian.common.TestObserver)3 AppInfo (org.apache.openejb.assembler.classic.AppInfo)3 WebAppInfo (org.apache.openejb.assembler.classic.WebAppInfo)3 PayaraClientException (fish.payara.arquillian.container.payara.clientutils.PayaraClientException)2 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 Properties (java.util.Properties)2 AppContext (org.apache.openejb.AppContext)2 NoSuchApplicationException (org.apache.openejb.NoSuchApplicationException)2 OpenEJBException (org.apache.openejb.OpenEJBException)2