Examples of DeployerException


Examples of org.ow2.util.ee.deploy.api.deployer.DeployerException

    protected static Method getMethod(final Class clazz, final String methodName, final Class... parameters)
        throws DeployerException {
        try {
            return clazz.getMethod(methodName, parameters);
        } catch (SecurityException e) {
            throw new DeployerException("Cannot get the Method '" + methodName + "' on the '" + clazz + "' class.", e);
        } catch (NoSuchMethodException e) {
            throw new DeployerException("Cannot get the Method '" + methodName + "' on the '" + clazz + "' class.", e);
        }
    }
View Full Code Here

Examples of org.ow2.util.ee.deploy.api.deployer.DeployerException

            // Register Object MBean
            try {
                CommonsModelerHelper.registerModelerMBean(standardContext, objectName);
            } catch (CommonsModelerException e) {
                throw new DeployerException("Cannot register the object '" + standardContext + "' with the objectname '"
                        + objectName + "'.", e);
            }

            // set the context-root

            standardContext.setPath(war.getContextRoot());

            // Get the URL for this War
            URL warURL = null;
            try {
                warURL = war.getArchive().getURL();
            } catch (ArchiveException e) {
                throw new DeployerException("Cannot get the URL for the archive '" + war.getArchive() + "'.", e);
            }

            // File of this war
            File warFile = URLUtils.urlToFile(warURL);

            // docbase
            String docBase = warFile.getPath();

            // File and not a directory --> unpack it
            if (warFile.isFile()) {
                // Need to unpack the file
                File unpackDir = unpack(warFile, war, earURL);
                docBase = unpackDir.getPath();
            }

            // set the path to the war file (needs to be unpacked else it will
            // be unpacked by tomcat in the webapps folder and it will try to
            // deploy twice the webapp with wrong classloader)
            standardContext.setDocBase(docBase);

            // default XML files
            standardContext.setDefaultWebXml("conf/web.xml");
            standardContext.setDefaultContextXml("context.xml");

            File contextXmlFile = new File(docBase + File.separator + "META-INF" + File.separator + "context.xml");
            // META-INF/context.xml file support
            if (contextXmlFile.exists()) {
                standardContext.setConfigFile(contextXmlFile.getAbsolutePath());
            }

            // Set the parent class loader
            standardContext.setParentClassLoader(parentClassLoader);

            // Set the java delegation model
            standardContext.setDelegate(true);

            // Start the context
            try {
                standardContext.start();
            } catch (Exception e) {
                throw new DeployerException("Cannot start the context of the War '" + warURL + "'.", e);
            }

            // War has been deployed
            logger.info("The war ''{0}'' has been deployed on the ''{1}'' context.", war, war.getContextRoot());
        }
View Full Code Here

Examples of org.ow2.util.ee.deploy.api.deployer.DeployerException

     * @throws DeployerException if this deployable is not supported.
     */
    private void checkSupportedDeployable(final IDeployable<?> deployable) throws DeployerException {
        if (!(EARDeployable.class.isAssignableFrom(deployable.getClass()) || EJBDeployable.class.isAssignableFrom(deployable
                .getClass()))) {
            throw new DeployerException("The deployable '" + deployable + "' is not supported by this deployer");
        }
    }
View Full Code Here

Examples of org.ow2.util.ee.deploy.api.deployer.DeployerException

        // Now, search the MBean of this context
        ObjectName contextObjectName = null;
        try {
            contextObjectName = new ObjectName(buildObjectName(warDeployable));
        } catch (MalformedObjectNameException e) {
            throw new DeployerException("Cannot get the ObjectName for the WAR deployable '" + warDeployable + "'.", e);
        } catch (NullPointerException e) {
            throw new DeployerException("Cannot get the ObjectName for the WAR deployable '" + warDeployable + "'.", e);
        }

        // Now, search if the MBean of this context is present
        try {
            if (!MBeanServerHelper.getMBeanServerServer().isRegistered(contextObjectName)) {
                throw new DeployerException("There is no MBean with the ObjectName '" + contextObjectName
                        + "' in the MBean Server for the WAR deployable '" + warDeployable + "'.");
            }
        } catch (JMXRemoteException e) {
            throw new DeployerException("Cannot check if the MBean with the ObjectName '" + contextObjectName
                    + "'is registered in the MBean Server for the WAR deployable '" + warDeployable + "'.");
        }

        // Undeploy
        try {
            MBeanServerHelper.getMBeanServerServer().invoke(contextObjectName, DESTROY_OPERATION, null, null);
        } catch (InstanceNotFoundException e) {
            throw new DeployerException("Cannot remove the context '" + contextRoot + "' of the war deployable '"
                    + warDeployable + "'.", e);
        } catch (MBeanException e) {
            throw new DeployerException("Cannot remove the context '" + contextRoot + "' of the war deployable '"
                    + warDeployable + "'.", e);
        } catch (ReflectionException e) {
            throw new DeployerException("Cannot remove the context '" + contextRoot + "' of the war deployable '"
                    + warDeployable + "'.", e);
        } catch (JMXRemoteException e) {
            throw new DeployerException("Cannot remove the context '" + contextRoot + "' of the war deployable '"
                    + warDeployable + "'.", e);
        }

        logger.info("The context ''{0}'' of the War ''{1}'' has been undeployed", contextRoot, warDeployable);
    }
View Full Code Here

Examples of org.ow2.util.ee.deploy.api.deployer.DeployerException

        // Build Engine object name
        ObjectName engineObjectName = null;
        try {
            engineObjectName = new ObjectName(ENGINE_OBJECT_NAME);
        } catch (MalformedObjectNameException e) {
            throw new DeployerException("Cannot build Tomcat Engine MBean.", e);
        } catch (NullPointerException e) {
            throw new DeployerException("Cannot build Tomcat Engine MBean.", e);
        }

        // Ask the MBean server
        Set<ObjectName> objectNames = null;
        try {
            // Get the list
            objectNames = MBeanServerHelper.getMBeanServerServer().queryNames(engineObjectName, null);
        } catch (JMXRemoteException e) {
            throw new DeployerException("Cannot get Tomcat Engine MBean.", e);
        }

        // Find objects ?
        if (objectNames.size() == 0) {
            throw new DeployerException("No Tomcat Engine MBean was found in the MBean server");
        }

        // Return the domain of this object name
        return (objectNames.iterator().next());
    }
View Full Code Here

Examples of org.ow2.util.ee.deploy.api.deployer.DeployerException

        // Get URL of this EAR
        URL earURL = null;
        try {
            earURL = earDeployable.getArchive().getURL();
        } catch (ArchiveException e) {
            throw new DeployerException("Cannot get the URL for the deployable '" + earDeployable + "'.", e);
        }

        // Create a Root classloader for this EAR
        // Empty classloader
        ClassLoader earClassLoader = new URLClassLoader(new URL[0], Thread.currentThread().getContextClassLoader());

        // Get EJBs of this EAR
        List<EJB3Deployable> ejb3s = earDeployable.getEJB3Deployables();

        // Get the URLs of EJB, WEB and Clients
        List<URL> urlsEJB = new ArrayList<URL>();
        for (EJB3Deployable ejb : ejb3s) {
            try {
                urlsEJB.add(ejb.getArchive().getURL());
            } catch (ArchiveException e) {
                throw new DeployerException("Cannot get the URL for the archive '" + ejb.getArchive() + "'", e);
            }
        }
        List<URL> urlsWAR = new ArrayList<URL>();
        for (WARDeployable war : earDeployable.getWARDeployables()) {
            try {
                urlsWAR.add(war.getArchive().getURL());
            } catch (ArchiveException e) {
                throw new DeployerException("Cannot get the URL for the archive '" + war.getArchive() + "'", e);
            }
        }
        List<URL> urlsClient = new ArrayList<URL>();
        for (CARDeployable car : earDeployable.getCARDeployables()) {
            try {
                urlsClient.add(car.getArchive().getURL());
            } catch (ArchiveException e) {
                throw new DeployerException("Cannot get the URL for the archive '" + car.getArchive() + "'", e);
            }
        }

        // Get libraries of this EAR
        List<LibDeployable> libs = earDeployable.getLibDeployables();

        // Create array of URLs with EJBs + Libraries
        List<URL> urls = new ArrayList<URL>();
        for (EJBDeployable<?> ejb : ejb3s) {
            try {
                urls.add(ejb.getArchive().getURL());
            } catch (ArchiveException e) {
                throw new DeployerException("Cannot get the URL for the Archive '" + ejb.getArchive() + "'.", e);
            }
        }
        for (LibDeployable lib : libs) {
            try {
                urls.add(lib.getArchive().getURL());
            } catch (ArchiveException e) {
                throw new DeployerException("Cannot get the URL for the Archive '" + lib.getArchive() + "'.", e);

            }
        }

        // Create classloader with these URLs
        URL[] arrayURLs = urls.toArray(new URL[urls.size()]);
        ClassLoader ejbClassLoader = new EasyBeansClassLoader(arrayURLs, Thread.currentThread().getContextClassLoader());

        // Get Persistence unit manager
        PersistenceUnitManager persistenceUnitManager = getPersistenceUnitManager(earDeployable, ejbClassLoader);

        // Get Extra libraries
        List<IArchive> libArchives = getLibArchives(earDeployable);


        // Create containers for each EJB deployable
        List<EZBContainer> containers = new ArrayList<EZBContainer>();
        for (EJBDeployable<?> ejb : ejb3s) {
            containers.add(getEmbedded().createContainer(ejb));
        }

        // Create Resolver for EAR
        EZBApplicationJNDIResolver applicationJNDIResolver = new ApplicationJNDIResolver();

        // Create EasyBeans injection Holder
        InjectionHolder ejbInjectionHolder = new InjectionHolder();
        ejbInjectionHolder.setPersistenceUnitManager(persistenceUnitManager);
        ejbInjectionHolder.setJNDIResolver(applicationJNDIResolver);

        // Configure containers
        for (EZBContainer container : containers) {
            // Set the classloader that needs to be used
            container.setClassLoader(ejbClassLoader);

            // Set application name
            container.setApplicationName(earDeployable.getModuleName());

            // Add persistence context found
            container.setPersistenceUnitManager(persistenceUnitManager);

            // Add the metadata
            container.setExtraArchives(libArchives);

            // set parent JNDI Resolver
            EZBContainerJNDIResolver containerJNDIResolver = container.getConfiguration().getContainerJNDIResolver();
            containerJNDIResolver.setApplicationJNDIResolver(applicationJNDIResolver);

            // Add child on application JNDI Resolver
            applicationJNDIResolver.addContainerJNDIResolver(containerJNDIResolver);

            // Resolve container
            try {
                container.resolve();
            } catch (EZBContainerException e) {
                throw new DeployerException("Cannot resolve the container '" + container.getArchive() + "'.", e);
            }

        }

        // Start containers
View Full Code Here

Examples of org.ow2.util.ee.deploy.api.deployer.DeployerException

    private String getDefaultHost() throws DeployerException {
        ObjectName engineObjectName = getEngineObjectName();
        try {
            return MBeanServerHelper.getMBeanServerServer().getAttribute(engineObjectName, "defaultHost").toString();
        } catch (AttributeNotFoundException e) {
            throw new DeployerException("Cannot get the default host on the object name '" + engineObjectName + "'.", e);
        } catch (InstanceNotFoundException e) {
            throw new DeployerException("Cannot get the default host on the object name '" + engineObjectName + "'.", e);
        } catch (MBeanException e) {
            throw new DeployerException("Cannot get the default host on the object name '" + engineObjectName + "'.", e);
        } catch (ReflectionException e) {
            throw new DeployerException("Cannot get the default host on the object name '" + engineObjectName + "'.", e);
        } catch (JMXRemoteException e) {
            throw new DeployerException("Cannot get the default host on the object name '" + engineObjectName + "'.", e);
        }
    }
View Full Code Here

Examples of org.ow2.util.ee.deploy.api.deployer.DeployerException

        // Build a JarFile on the war
        JarFile packedJar;
        try {
            packedJar = new JarFile(warFile);
        } catch (IOException e) {
            throw new DeployerException("The war file '" + warFile + "' is not a valid war file", e);
        }

        // Unpack the war
        try {
            FileUtils.unpack(packedJar, unpackDir);
        } catch (FileUtilsException e) {
            throw new DeployerException("Cannot unpack the file '" + packedJar + "' in the directory '" + unpackDir + "'.", e);
        }

        return unpackDir;

    }
View Full Code Here

Examples of org.ow2.util.ee.deploy.api.deployer.DeployerException

     * @throws DeployerException if this deployable is not supported.
     */
    private void checkSupportedDeployable(final IDeployable<?> deployable) throws DeployerException {
        if (!(EARDeployable.class.isAssignableFrom(deployable.getClass()) || EJBDeployable.class.isAssignableFrom(deployable
                .getClass()))) {
            throw new DeployerException("The deployable '" + deployable + "' is not supported by this deployer");
        }
    }
View Full Code Here

Examples of org.ow2.util.ee.deploy.api.deployer.DeployerException

        super();

        // First, try to get the source on the given context event
        Object source = servletContextEvent.getSource();
        if (source == null) {
            throw new DeployerException("No source object on the given contextEvent '" + servletContextEvent + "'.");
        }

        if (!(source instanceof Context)) {
             throw new DeployerException("Invalid source object '" + source + "'.");
        }
        Context context = (Context) source;
        ContextHandler contextHandler = context.getContextHandler();
        this.jettyServer = contextHandler.getServer();

        // No server ?
        if (this.jettyServer == null) {
            throw new DeployerException("No Jetty server found on the servlet context event '" + servletContextEvent + "'.");
        }

        // Get handler collection
        HandlerCollection handlerCollection = (HandlerCollection) this.jettyServer
                .getChildHandlerByClass(HandlerCollection.class);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.