Example usage for javax.naming Context lookup

List of usage examples for javax.naming Context lookup

Introduction

In this page you can find the example usage for javax.naming Context lookup.

Prototype

public Object lookup(String name) throws NamingException;

Source Link

Document

Retrieves the named object.

Usage

From source file:org.apache.myfaces.ov2021.application.ApplicationImpl.java

@Override
public ProjectStage getProjectStage() {
    // If the value has already been determined by a previous call to this
    // method, simply return that value.
    if (_projectStage == null) {
        String stageName = null;/*from ww  w . j a va  2  s  .com*/

        // try to obtain the ProjectStage from the system property
        // faces.PROJECT_STAGE as proposed by Ed Burns
        stageName = System.getProperty(PROJECT_STAGE_SYSTEM_PROPERTY_NAME);

        if (stageName == null) {
            // if not found check for the "old" System Property
            // and print a warning message to the log (just to be 
            // sure that everyone recognizes the change in the name).
            stageName = System.getProperty(MYFACES_PROJECT_STAGE_SYSTEM_PROPERTY_NAME);
            if (stageName != null) {
                log.log(Level.WARNING,
                        "The system property " + MYFACES_PROJECT_STAGE_SYSTEM_PROPERTY_NAME
                                + " has been replaced by " + PROJECT_STAGE_SYSTEM_PROPERTY_NAME + "!"
                                + " Please change your settings.");
            }
        }

        if (stageName == null) {
            // Look for a JNDI environment entry under the key given by the
            // value of ProjectStage.PROJECT_STAGE_JNDI_NAME (return type of
            // java.lang.String).
            try {
                Context ctx = new InitialContext();
                Object temp = ctx.lookup(ProjectStage.PROJECT_STAGE_JNDI_NAME);
                if (temp != null) {
                    if (temp instanceof String) {
                        stageName = (String) temp;
                    } else {
                        log.severe("JNDI lookup for key " + ProjectStage.PROJECT_STAGE_JNDI_NAME
                                + " should return a java.lang.String value");
                    }
                }
            } catch (NamingException e) {
                // no-op
            } catch (NoClassDefFoundError er) {
                //On Google App Engine, javax.naming.Context is a restricted class.
                //In that case, NoClassDefFoundError is thrown. stageName needs to be configured
                //below by context parameter.
                //It can be done with changing the order to look first at
                // context param, but it is defined in the spec.
                //http://java.sun.com/javaee/6/docs/api/javax/faces/application/Application.html#getProjectStage()
                //no-op
            }
        }

        /*
         * If found, continue with the algorithm below, otherwise, look for an entry in the initParamMap of the
         * ExternalContext from the current FacesContext with the key ProjectStage.PROJECT_STAGE_PARAM_NAME
         */
        if (stageName == null) {
            FacesContext context = FacesContext.getCurrentInstance();
            stageName = context.getExternalContext().getInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME);
        }

        // If a value is found
        if (stageName != null) {
            /*
             * see if an enum constant can be obtained by calling ProjectStage.valueOf(), passing 
             * the value from the initParamMap. If this succeeds without exception, save the value 
             * and return it.
             */
            try {
                _projectStage = ProjectStage.valueOf(stageName);
                return _projectStage;
            } catch (IllegalArgumentException e) {
                log.log(Level.SEVERE, "Couldn't discover the current project stage", e);
            }
        } else {
            if (log.isLoggable(Level.INFO)) {
                log.info("Couldn't discover the current project stage, using " + ProjectStage.Production);
            }
        }

        /*
         * If not found, or any of the previous attempts to discover the enum constant value have failed, log a
         * descriptive error message, assign the value as ProjectStage.Production and return it.
         */

        _projectStage = ProjectStage.Production;
    }

    return _projectStage;
}

From source file:org.apache.myfaces.application.ApplicationImpl.java

@Override
public ProjectStage getProjectStage() {
    // If the value has already been determined by a previous call to this
    // method, simply return that value.
    if (_projectStage == null) {
        String stageName = null;/*from w ww. j av a 2  s.  c om*/

        // try to obtain the ProjectStage from the system property
        // faces.PROJECT_STAGE as proposed by Ed Burns
        stageName = System.getProperty(PROJECT_STAGE_SYSTEM_PROPERTY_NAME);

        if (stageName == null) {
            // if not found check for the "old" System Property
            // and print a warning message to the log (just to be 
            // sure that everyone recognizes the change in the name).
            stageName = System.getProperty(MYFACES_PROJECT_STAGE_SYSTEM_PROPERTY_NAME);
            if (stageName != null) {
                log.log(Level.WARNING,
                        "The system property " + MYFACES_PROJECT_STAGE_SYSTEM_PROPERTY_NAME
                                + " has been replaced by " + PROJECT_STAGE_SYSTEM_PROPERTY_NAME + "!"
                                + " Please change your settings.");
            }
        }

        if (stageName == null) {
            // Look for a JNDI environment entry under the key given by the
            // value of ProjectStage.PROJECT_STAGE_JNDI_NAME (return type of
            // java.lang.String).
            try {
                Context ctx = new InitialContext();
                Object temp = ctx.lookup(ProjectStage.PROJECT_STAGE_JNDI_NAME);
                if (temp != null) {
                    if (temp instanceof String) {
                        stageName = (String) temp;
                    } else {
                        log.severe("JNDI lookup for key " + ProjectStage.PROJECT_STAGE_JNDI_NAME
                                + " should return a java.lang.String value");
                    }
                }
            } catch (NamingException e) {
                // no-op
            } catch (NoClassDefFoundError er) {
                //On Google App Engine, javax.naming.Context is a restricted class.
                //In that case, NoClassDefFoundError is thrown. stageName needs to be configured
                //below by context parameter.
                //It can be done with changing the order to look first at
                // context param, but it is defined in the spec.
                //http://java.sun.com/javaee/6/docs/api/javax/faces/application/Application.html#getProjectStage()
                //no-op
            }
        }

        /*
         * If found, continue with the algorithm below, otherwise, look for an entry in the initParamMap of the
         * ExternalContext from the current FacesContext with the key ProjectStage.PROJECT_STAGE_PARAM_NAME
         */
        if (stageName == null) {
            FacesContext context = FacesContext.getCurrentInstance();
            stageName = context.getExternalContext().getInitParameter(ProjectStage.PROJECT_STAGE_PARAM_NAME);
        }

        // If a value is found
        if (stageName != null) {
            /*
             * see if an enum constant can be obtained by calling ProjectStage.valueOf(), passing 
             * the value from the initParamMap. If this succeeds without exception, save the value 
             * and return it.
             */
            try {
                _projectStage = ProjectStage.valueOf(stageName);
                return _projectStage;
            } catch (IllegalArgumentException e) {
                log.log(Level.INFO, "Couldn't discover the current project stage: " + stageName);
            }
        } else {
            if (log.isLoggable(Level.INFO)) {
                log.info("Couldn't discover the current project stage, using " + ProjectStage.Production);
            }
        }

        /*
         * If not found, or any of the previous attempts to discover the enum constant value have failed, log a
         * descriptive error message, assign the value as ProjectStage.Production and return it.
         */

        _projectStage = ProjectStage.Production;
    }

    return _projectStage;
}

From source file:de.unibi.techfak.bibiserv.BiBiTools.java

/**
 * Return datasource used by this BiBiTools class.
 *
 * If (BiBiTool Property ('useDebugDataSource') is set to true, then a
 * DebugDataSource is used instead of a normal one.
 *
 * @see DDataSource// w w  w  .  j  a v a2s .  co m
 *
 * @return
 */
public static DataSource getDataSource() throws DBConnectionException {
    if (BiBiTools.datasource == null) {
        try {
            Context ctx = new InitialContext();
            if (ctx == null) {
                log.error("context is null");
                throw new DBConnectionException();
            }
            // @todo: Hardcoded DataSource !!!
            if (Boolean.parseBoolean(getProperties().getProperty("useDebugDataSource", "false"))) {
                BiBiTools.datasource = new DDataSource((DataSource) ctx.lookup("jdbc/bibiserv2"));
            } else {
                BiBiTools.datasource = (DataSource) ctx.lookup("jdbc/bibiserv2");
            }
        } catch (NamingException ex) {
            log.fatal("An NamingException occurred : " + ex.getMessage());
            throw new DBConnectionException();
        }
    }
    return BiBiTools.datasource;
}

From source file:hermes.browser.HermesBrowser.java

/**
 * Initialise the underlying Hermes that we're gonna do all our work with
 * //www  .  jav  a 2 s. c om
 * @throws HermesException
 * @throws NamingException
 */
public void loadConfig() throws NamingException, HermesException {
    Properties props = new Properties();
    Context oldContext = context;
    HermesConfig oldConfig = null;

    props.put(Context.INITIAL_CONTEXT_FACTORY, HermesInitialContextFactory.class.getName());
    props.put(Context.PROVIDER_URL, getCurrentConfigURL());
    props.put("hermes.loader", JAXBHermesLoader.class.getName());

    log.debug("props=" + props);

    Iterator listeners = null;

    if (loader != null) {
        listeners = loader.getConfigurationListeners();
        oldConfig = loader.getConfig();
    }

    if (oldConfig != null) {
        Set naming = new HashSet();
        naming.addAll(oldConfig.getNaming());

        for (Iterator iter = naming.iterator(); iter.hasNext();) {
            NamingConfig oldNaming = (NamingConfig) iter.next();

            loader.notifyNamingRemoved(oldNaming);
        }
    }

    context = new InitialContext(props);
    loader = (HermesLoader) context.lookup(HermesContext.LOADER);

    if (listeners != null) {
        while (listeners.hasNext()) {
            loader.addConfigurationListener((HermesConfigurationListener) listeners.next());
        }
    }

    if (oldContext != null) {
        for (NamingEnumeration iter = oldContext.listBindings(""); iter.hasMoreElements();) {
            Binding binding = (Binding) iter.next();

            try {
                if (oldContext.lookup(binding.getName()) instanceof Hermes) {
                    Hermes hermes = (Hermes) oldContext.lookup(binding.getName());
                    Hermes newHermes = null;

                    try {
                        newHermes = (Hermes) context.lookup(hermes.getId());
                    } catch (NamingException e) {
                        // NOP
                    }

                    if (newHermes == null) {
                        loader.notifyHermesRemoved(hermes);
                    }
                }
            } catch (NamingException ex) {
                // NOP
            }
        }
    }

    if (!firstLoad) {
        closeWatches();
        final ArrayList tmpList = new ArrayList();
        tmpList.addAll(loader.getConfig().getWatch());
        loader.getConfig().getWatch().clear();

        for (Iterator iter = tmpList.iterator(); iter.hasNext();) {
            WatchConfig wConfig = (WatchConfig) iter.next();
            createWatch(wConfig);
        }
    }

    setTitle("HermesJMS - " + TextUtils.crumble(getCurrentConfigURL(), 100));
}

From source file:org.freebxml.omar.server.persistence.rdb.SQLPersistenceManagerImpl.java

private SQLPersistenceManagerImpl() {
    loadUsernamePassword();/*from w w  w  .  java2 s . com*/
    constructDatabaseURL();

    // define transaction isolation
    if ("TRANSACTION_READ_COMMITTED".equalsIgnoreCase(
            RegistryProperties.getInstance().getProperty("omar.persistence.rdb.transactionIsolation"))) {
        transactionIsolation = Connection.TRANSACTION_READ_COMMITTED;
    } else {
        transactionIsolation = Connection.TRANSACTION_READ_UNCOMMITTED;
    }

    useConnectionPool = Boolean.valueOf(
            RegistryProperties.getInstance().getProperty("omar.persistence.rdb.useConnectionPooling", "true"))
            .booleanValue();
    skipReferenceCheckOnRemove = Boolean.valueOf(RegistryProperties.getInstance()
            .getProperty("omar.persistence.rdb.skipReferenceCheckOnRemove", "false")).booleanValue();
    dumpStackOnQuery = Boolean.valueOf(
            RegistryProperties.getInstance().getProperty("omar.persistence.rdb.dumpStackOnQuery", "false"))
            .booleanValue();
    boolean debugConnectionPool = Boolean
            .valueOf(RegistryProperties.getInstance().getProperty("omar.persistence.rdb.pool.debug", "false"))
            .booleanValue();

    //Create JNDI context
    if (useConnectionPool) {
        if (!debugConnectionPool) {
            // Use Container's connection pooling
            String omarName = RegistryProperties.getInstance().getProperty("omar.name", "omar");
            String envName = "java:comp/env";
            String dataSourceName = "jdbc/" + omarName + "-registry";
            Context ctx = null;

            try {
                ctx = new InitialContext();
                if (null == ctx) {
                    log.info(ServerResourceBundle.getInstance().getString("message.UnableToGetInitialContext"));
                }
            } catch (NamingException e) {
                log.info(ServerResourceBundle.getInstance().getString("message.UnableToGetInitialContext"), e);
                ctx = null;
            }

            /* HIEOS/BHT: DISABLED
            if (null != ctx) {
            try {
            ctx = (Context)ctx.lookup(envName);
            if (null == ctx) {
            log.info(ServerResourceBundle.getInstance().
            getString("message.UnableToGetJNDIContextForDataSource",
            new Object[]{envName}));
            }
            } catch (NamingException e) {
            log.info(ServerResourceBundle.getInstance().
            getString("message.UnableToGetJNDIContextForDataSource",
            new Object[]{envName}), e);
            ctx = null;
            }
            }
             */

            if (null != ctx) {
                try {
                    ds = (DataSource) ctx.lookup(dataSourceName);
                    if (null == ds) {
                        log.info(ServerResourceBundle.getInstance().getString(
                                "message.UnableToGetJNDIContextForDataSource",
                                new Object[] { envName + "/" + dataSourceName }));
                    }
                } catch (NamingException e) {
                    log.info(ServerResourceBundle.getInstance().getString(
                            "message.UnableToGetJNDIContextForDataSource",
                            new Object[] { envName + "/" + dataSourceName }), e);
                    ds = null;
                }
            }

            if (null != ds) {
                // Create a test connection to make sure all is well with DataSource
                Connection connection = null;
                try {
                    connection = ds.getConnection();
                } catch (Exception e) {
                    log.info(ServerResourceBundle.getInstance().getString(
                            "message.UnableToCreateTestConnectionForDataSource",
                            new Object[] { envName + "/" + dataSourceName }), e);
                    ds = null;
                } finally {
                    if (connection != null) {
                        try {
                            connection.close();
                        } catch (Exception e1) {
                            //Do nothing.
                        }
                    }
                }
            }
        }

        if (ds == null) {
            // No DataSource available so create our own ConnectionPool
            loadDatabaseDriver();
            createConnectionPool();
        }
    } else {
        loadDatabaseDriver();
    }
}

From source file:org.gss_project.gss.server.ejb.ExternalAPIBean.java

private void indexFile(Long fileId, boolean delete) {
     Connection qConn = null;/*  w  ww  .  ja  v  a  2  s  . co m*/
     Session session = null;
     MessageProducer sender = null;
     try {
         Context jndiCtx = new InitialContext();
         ConnectionFactory factory = (QueueConnectionFactory) jndiCtx.lookup("java:/JmsXA");
         Queue queue = (Queue) jndiCtx.lookup("queue/gss-indexingQueue");
         qConn = factory.createConnection();
         session = qConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
         sender = session.createProducer(queue);

         MapMessage map = session.createMapMessage();
         map.setObject("id", fileId);
         map.setBoolean("delete", delete);
         sender.send(map);
     } catch (NamingException e) {
         logger.error("Index was not updated: ", e);
     } catch (JMSException e) {
         logger.error("Index was not updated: ", e);
     } finally {
         try {
             if (sender != null)
                 sender.close();
             if (session != null)
                 session.close();
             if (qConn != null)
                 qConn.close();
         } catch (JMSException e) {
             logger.warn(e);
         }
     }
 }

From source file:com.hiperf.common.ui.server.storage.impl.PersistenceHelper.java

private PersistenceHelper(TYPE t, String unitName) {
    startLicenseCheck();// www  . j  a  va 2s.  c om

    this.type = t;
    try {
        emf = Persistence.createEntityManagerFactory(unitName);
        emByThread = new ThreadLocal<EntityManager>();
    } catch (Exception ee) {
        logger.log(Level.SEVERE, "Exception while init Persistence.xml...", ee);
        throw new RuntimeException(ee);
    }
    if (this.type.equals(TYPE.JTA)) {
        try {
            Context c = new InitialContext();
            tx = new JtaTransaction((UserTransaction) c.lookup("java:comp/UserTransaction"));
        } catch (NamingException e) {
            logger.log(Level.SEVERE, "Exception while initializing PersistenceHelper in JTA...", e);
            type = TYPE.LOCAL;
        }
    }
    if (emf.getMetamodel().getEntities() != null && !emf.getMetamodel().getEntities().isEmpty()) {
        for (EntityType e : emf.getMetamodel().getEntities()) {
            try {
                initClassMapping(e.getBindableJavaType().getName());
            } catch (Exception e1) {
                logger.log(Level.SEVERE, "Exception", e1);
            }
        }
    }
    endLicenseCheck();

}

From source file:com.xpn.xwiki.XWiki.java

public static String getConfigPath() throws NamingException {
    if (configPath == null) {
        try {//from   w ww.  ja v a2s . c om
            Context envContext = (Context) new InitialContext().lookup("java:comp/env");
            configPath = (String) envContext.lookup(CFG_ENV_NAME);
        } catch (Exception e) {
            configPath = "/WEB-INF/xwiki.cfg";
            LOGGER.debug("The xwiki.cfg file will be read from [" + configPath + "] because "
                    + "its location couldn't be read from the JNDI [" + CFG_ENV_NAME + "] "
                    + "variable in [java:comp/env].");
        }
    }

    return configPath;
}

From source file:org.apache.openejb.assembler.classic.Assembler.java

public synchronized void destroyApplication(AppInfo appInfo) throws UndeployException {
    deployedApplications.remove(appInfo.path);
    logger.info("destroyApplication.start", appInfo.path);

    fireBeforeApplicationDestroyed(appInfo);

    final AppContext appContext = containerSystem.getAppContext(appInfo.appId);

    for (Map.Entry<String, Object> value : appContext.getBindings().entrySet()) {
        String path = value.getKey();
        if (path.startsWith("global")) {
            path = "java:" + path;
        }//from  w ww.ja va  2 s. co  m
        if (!path.startsWith("java:global")) {
            continue;
        }

        try {
            containerSystem.getJNDIContext().unbind(path);
        } catch (NamingException ignored) {
            // no-op
        }
    }
    try {
        containerSystem.getJNDIContext().unbind("java:global");
    } catch (NamingException ignored) {
        // no-op
    }

    EjbResolver globalResolver = new EjbResolver(null, EjbResolver.Scope.GLOBAL);
    for (AppInfo info : deployedApplications.values()) {
        globalResolver.addAll(info.ejbJars);
    }
    SystemInstance.get().setComponent(EjbResolver.class, globalResolver);

    Context globalContext = containerSystem.getJNDIContext();
    UndeployException undeployException = new UndeployException(
            messages.format("destroyApplication.failed", appInfo.path));

    WebAppBuilder webAppBuilder = SystemInstance.get().getComponent(WebAppBuilder.class);
    if (webAppBuilder != null) {
        try {
            webAppBuilder.undeployWebApps(appInfo);
        } catch (Exception e) {
            undeployException.getCauses().add(new Exception("App: " + appInfo.path + ": " + e.getMessage(), e));
        }
    }

    // get all of the ejb deployments
    List<BeanContext> deployments = new ArrayList<BeanContext>();
    for (EjbJarInfo ejbJarInfo : appInfo.ejbJars) {
        for (EnterpriseBeanInfo beanInfo : ejbJarInfo.enterpriseBeans) {
            String deploymentId = beanInfo.ejbDeploymentId;
            BeanContext beanContext = containerSystem.getBeanContext(deploymentId);
            if (beanContext == null) {
                undeployException.getCauses().add(new Exception("deployment not found: " + deploymentId));
            } else {
                deployments.add(beanContext);
            }
        }
    }

    // Just as with startup we need to get things in an
    // order that respects the singleton @DependsOn information
    // Theoreticlly if a Singleton depends on something in its
    // @PostConstruct, it can depend on it in its @PreDestroy.
    // Therefore we want to make sure that if A dependsOn B,
    // that we destroy A first then B so that B will still be
    // usable in the @PreDestroy method of A.

    // Sort them into the original starting order
    deployments = sort(deployments);
    // reverse that to get the stopping order
    Collections.reverse(deployments);

    // stop
    for (BeanContext deployment : deployments) {
        String deploymentID = deployment.getDeploymentID() + "";
        try {
            Container container = deployment.getContainer();
            container.stop(deployment);
        } catch (Throwable t) {
            undeployException.getCauses()
                    .add(new Exception("bean: " + deploymentID + ": " + t.getMessage(), t));
        }
    }

    // undeploy
    for (BeanContext bean : deployments) {
        String deploymentID = bean.getDeploymentID() + "";
        try {
            Container container = bean.getContainer();
            container.undeploy(bean);
            bean.setContainer(null);
        } catch (Throwable t) {
            undeployException.getCauses()
                    .add(new Exception("bean: " + deploymentID + ": " + t.getMessage(), t));
        } finally {
            bean.setDestroyed(true);
        }
    }

    // get the client ids
    List<String> clientIds = new ArrayList<String>();
    for (ClientInfo clientInfo : appInfo.clients) {
        clientIds.add(clientInfo.moduleId);
        for (String className : clientInfo.localClients) {
            clientIds.add(className);
        }
        for (String className : clientInfo.remoteClients) {
            clientIds.add(className);
        }
    }

    if (appContext != null)
        for (WebContext webContext : appContext.getWebContexts()) {
            containerSystem.removeWebContext(webContext);
        }

    // Clear out naming for all components first
    for (BeanContext deployment : deployments) {
        String deploymentID = deployment.getDeploymentID() + "";
        try {
            containerSystem.removeBeanContext(deployment);
        } catch (Throwable t) {
            undeployException.getCauses().add(new Exception(deploymentID, t));
        }

        JndiBuilder.Bindings bindings = deployment.get(JndiBuilder.Bindings.class);
        if (bindings != null)
            for (String name : bindings.getBindings()) {
                try {
                    globalContext.unbind(name);
                } catch (Throwable t) {
                    undeployException.getCauses()
                            .add(new Exception("bean: " + deploymentID + ": " + t.getMessage(), t));
                }
            }
    }

    for (PersistenceUnitInfo unitInfo : appInfo.persistenceUnits) {
        try {
            Object object = globalContext.lookup(PERSISTENCE_UNIT_NAMING_CONTEXT + unitInfo.id);
            globalContext.unbind(PERSISTENCE_UNIT_NAMING_CONTEXT + unitInfo.id);

            // close EMF so all resources are released
            ReloadableEntityManagerFactory remf = ((ReloadableEntityManagerFactory) object);
            remf.close();
            persistenceClassLoaderHandler.destroy(unitInfo.id);
            remf.unregister();
        } catch (Throwable t) {
            undeployException.getCauses()
                    .add(new Exception("persistence-unit: " + unitInfo.id + ": " + t.getMessage(), t));
        }
    }

    for (String sId : moduleIds) {
        try {
            globalContext.unbind(VALIDATOR_FACTORY_NAMING_CONTEXT + sId);
            globalContext.unbind(VALIDATOR_NAMING_CONTEXT + sId);
        } catch (NamingException e) {
            undeployException.getCauses().add(new Exception("validator: " + sId + ": " + e.getMessage(), e));
        }
    }
    moduleIds.clear();

    try {
        if (globalContext instanceof IvmContext) {
            IvmContext ivmContext = (IvmContext) globalContext;
            ivmContext.prune("openejb/Deployment");
            ivmContext.prune("openejb/local");
            ivmContext.prune("openejb/remote");
            ivmContext.prune("openejb/global");
        }
    } catch (NamingException e) {
        undeployException.getCauses().add(new Exception(
                "Unable to prune openejb/Deployments and openejb/local namespaces, this could cause future deployments to fail.",
                e));
    }

    deployments.clear();

    for (String clientId : clientIds) {
        try {
            globalContext.unbind("/openejb/client/" + clientId);
        } catch (Throwable t) {
            undeployException.getCauses().add(new Exception("client: " + clientId + ": " + t.getMessage(), t));
        }
    }

    // mbeans
    MBeanServer server = LocalMBeanServer.get();
    for (String objectName : appInfo.jmx) {
        try {
            ObjectName on = new ObjectName(objectName);
            if (server.isRegistered(on)) {
                server.unregisterMBean(on);
            }
        } catch (InstanceNotFoundException e) {
            logger.warning("can't unregister " + objectName + " because the mbean was not found", e);
        } catch (MBeanRegistrationException e) {
            logger.warning("can't unregister " + objectName, e);
        } catch (MalformedObjectNameException mone) {
            logger.warning("can't unregister because the ObjectName is malformed: " + objectName, mone);
        }
    }

    containerSystem.removeAppContext(appInfo.appId);

    ClassLoaderUtil.destroyClassLoader(appInfo.path);

    if (undeployException.getCauses().size() > 0) {
        throw undeployException;
    }

    logger.debug("destroyApplication.success", appInfo.path);
}