Example usage for org.springframework.context ApplicationContextException ApplicationContextException

List of usage examples for org.springframework.context ApplicationContextException ApplicationContextException

Introduction

In this page you can find the example usage for org.springframework.context ApplicationContextException ApplicationContextException.

Prototype

public ApplicationContextException(String msg, Throwable cause) 

Source Link

Document

Create a new ApplicationContextException with the specified detail message and the given root cause.

Usage

From source file:com.cisco.dvbu.ps.deploytool.services.RegressionManagerImpl.java

private RegressionSecurityType getRegressionSecurity(String serverId, String regressionIds,
        String pathToRegressionXML, String pathToServersXML) {

    // Validate whether the files exist or not
    if (!CommonUtils.fileExists(pathToRegressionXML)) {
        throw new CompositeException("File [" + pathToRegressionXML + "] does not exist.");
    }/*from  www. j av a2 s  . c  om*/

    // validate incoming arguments
    if (serverId == null || serverId.trim().length() == 0 || regressionIds == null
            || regressionIds.trim().length() == 0 || pathToRegressionXML.trim().length() == 0) {
        throw new ValidationException("Invalid Arguments");
    }

    try {
        //using jaxb convert xml to corresponding java objects
        RegressionModule regressionModule = (RegressionModule) XMLUtils
                .getModuleTypeFromXML(pathToRegressionXML);

        // Get the regression tests
        if (regressionModule != null && regressionModule.getRegressionSecurity() != null) {
            return regressionModule.getRegressionSecurity();
        }
    } catch (CompositeException e) {
        logger.error("Error while parsing RegressionModule XML: ", e);
        throw new ApplicationContextException(e.getMessage(), e);
    }
    return null;
}

From source file:com.cisco.dvbu.ps.deploytool.services.VCSManagerImpl.java

private List<VCSResourceType> getVCSResources(String serverId, String vcsId, String pathToVcsXML,
        String pathToServersXML) {
    // validate incoming arguments
    if (serverId == null || serverId.trim().length() == 0 || vcsId == null || vcsId.trim().length() == 0
            || pathToServersXML == null || pathToServersXML.trim().length() == 0 || pathToVcsXML == null
            || pathToVcsXML.trim().length() == 0) {
        throw new ValidationException("Invalid Arguments");
    }/*from  w  ww . j  a  v a 2 s . c o  m*/

    try {
        //using jaxb convert xml to corresponding java objects
        VCSModule vcsModuleType = (VCSModule) XMLUtils.getModuleTypeFromXML(pathToVcsXML);

        if (vcsModuleType != null && vcsModuleType.getVcsResource() != null
                && !vcsModuleType.getVcsResource().isEmpty()) {
            return vcsModuleType.getVcsResource();
        }
    } catch (CompositeException e) {
        CompositeServer targetServer = WsApiHelperObjects.getServer(serverId, pathToServersXML);
        String errorMessage = DeployUtil.constructMessage(DeployUtil.MessageType.ERROR.name(),
                "Parse VCSModule XML", "getVCSResources", pathToVcsXML, targetServer);

        logger.error(errorMessage, e);
        throw new ApplicationContextException(errorMessage, e);
    }
    return null;
}

From source file:com.laxser.blitz.lama.core.LamaDaoProcessor.java

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    if (logger.isInfoEnabled()) {
        logger.info("[jade] starting ...");
    }/*w w  w . jav  a  2 s  .c  o m*/
    final List<ResourceRef> resources;
    try {
        resources = BlitzScanner.getInstance().getJarOrClassesFolderResources();
    } catch (IOException e) {
        throw new ApplicationContextException("error on getJarResources/getClassesFolderResources", e);
    }
    List<String> urls = new LinkedList<String>();
    for (ResourceRef resourceInfo : resources) {
        if (resourceInfo.hasModifier("dao") || resourceInfo.hasModifier("DAO")) {
            try {
                Resource resource = resourceInfo.getResource();
                File resourceFile = resource.getFile();
                if (resourceFile.isFile()) {
                    urls.add("jar:file:" + resourceFile.toURI().getPath() + ResourceUtils.JAR_URL_SEPARATOR);
                } else if (resourceFile.isDirectory()) {
                    urls.add(resourceFile.toURI().toString());
                }
            } catch (IOException e) {
                throw new ApplicationContextException("error on resource.getFile", e);
            }
        }
    }

    if (logger.isInfoEnabled()) {
        logger.info("[jade] found " + urls.size() + " jade urls: " + urls);
    }
    if (urls.size() > 0) {
        LamaDaoComponentProvider provider = new LamaDaoComponentProvider(true);
        if (filters != null) {
            for (TypeFilter excludeFilter : filters) {
                provider.addExcludeFilter(excludeFilter);
            }
        }

        final DataAccessProvider dataAccessProvider = createJdbcTemplateDataAccessProvider();

        Set<String> daoClassNames = new HashSet<String>();

        for (String url : urls) {
            if (logger.isInfoEnabled()) {
                logger.info("[jade] call 'jade/find'");
            }
            Set<BeanDefinition> dfs = provider.findCandidateComponents(url);
            if (logger.isInfoEnabled()) {
                logger.info("[jade] found " + dfs.size()//
                        + " beanDefinition from '" + url + "'");
            }
            for (BeanDefinition beanDefinition : dfs) {
                String daoClassName = beanDefinition.getBeanClassName();

                if (daoClassNames.contains(daoClassName)) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("[jade] ignored replicated jade dao class: " + daoClassName + "  [" + url
                                + "]");
                    }
                    continue;
                }
                daoClassNames.add(daoClassName);

                MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();
                propertyValues.addPropertyValue("dataAccessProvider", dataAccessProvider);
                propertyValues.addPropertyValue("daoClass", daoClassName);
                ScannedGenericBeanDefinition scannedBeanDefinition = (ScannedGenericBeanDefinition) beanDefinition;
                scannedBeanDefinition.setPropertyValues(propertyValues);
                scannedBeanDefinition.setBeanClass(LamaDaoFactoryBean.class);

                DefaultListableBeanFactory defaultBeanFactory = (DefaultListableBeanFactory) beanFactory;
                defaultBeanFactory.registerBeanDefinition(daoClassName, beanDefinition);

                if (logger.isDebugEnabled()) {
                    logger.debug("[jade] register jade dao bean: " + daoClassName);
                }
            }
        }
    }
    if (logger.isInfoEnabled()) {
        logger.info("[jade] exits");
    }
}

From source file:com.workingmouse.webservice.axis.SpringAxisServlet.java

/**
 * Initialize and publish the WebApplicationContext for the SpringAxisServlet.
 * Delegates to createWebApplicationContext for actual creation.
 * Can be overridden in subclasses./*from  w  w  w  .j a v  a 2s .c  o m*/
 *
 * @throws org.springframework.beans.BeansException
 *      if the context couldn't be initialized
 *
 * @see #createWebApplicationContext
 */
protected WebApplicationContext initWebApplicationContext() throws BeansException {
    log("Initializing WebApplicationContext for servlet '" + this.getServletName() + "'");

    ServletContext ctx = getServletContext();
    WebApplicationContext parent = WebApplicationContextUtils.getWebApplicationContext(ctx);

    WebApplicationContext wac = createWebApplicationContext(parent);
    if (LOG.isDebugEnabled()) {
        LOG.debug("Using context class '" + wac.getClass().getName() + "' for servlet '" + getServletName()
                + "'");
    }

    // publish the context to axis engine application session
    try {
        SpringBeanProvider.setWebApplicationContext(getEngine(), wac);
    } catch (AxisFault e) {
        throw new ApplicationContextException("Could not save axis engine session object", e);
    }
    return wac;
}

From source file:net.paoding.rose.jade.context.spring.JadeBeanFactoryPostProcessor.java

@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    String postProcessor = System.getProperty("jade.spring.postProcessor");
    if ("disable".equals(postProcessor)) {
        logger.info("jade.spring.postProcessor: disable");
        return;//www.j  ava2  s.  co m
    } else if (postProcessor == null || "enable".equals(postProcessor)) {
        logger.info("jade.spring.postProcessor: enable");
    } else {
        throw new IllegalArgumentException(//
                "illegal property of 'jade.spring.postProcessor': " + postProcessor);
    }
    if (logger.isInfoEnabled()) {
        logger.info("[jade] starting ...");
    }
    final List<ResourceRef> resources;
    try {
        // scope
        resources = RoseScanner.getInstance().getJarOrClassesFolderResources();
    } catch (IOException e) {
        throw new ApplicationContextException("error on getJarResources/getClassesFolderResources", e);
    }
    List<String> urls = new LinkedList<String>();
    for (ResourceRef ref : resources) {
        if (ref.hasModifier("dao") || ref.hasModifier("DAO")) {
            try {
                Resource resource = ref.getResource();
                File resourceFile = resource.getFile();
                if (resourceFile.isFile()) {
                    urls.add("jar:file:" + resourceFile.toURI().getPath() + ResourceUtils.JAR_URL_SEPARATOR);
                } else if (resourceFile.isDirectory()) {
                    urls.add(resourceFile.toURI().toString());
                }
            } catch (IOException e) {
                throw new ApplicationContextException("error on resource.getFile", e);
            }
        }
    }

    if (logger.isInfoEnabled()) {
        logger.info("[jade] found " + urls.size() + " jade urls: " + urls);
    }
    if (urls.size() > 0) {
        DAOComponentProvider provider = new DAOComponentProvider(true);
        if (filters != null) {
            for (TypeFilter excludeFilter : filters) {
                provider.addExcludeFilter(excludeFilter);
            }
        }

        Set<String> daoClassNames = new HashSet<String>();

        for (String url : urls) {
            if (logger.isInfoEnabled()) {
                logger.info("[jade] call 'jade/find'");
            }
            Set<BeanDefinition> dfs = provider.findCandidateComponents(url);
            if (logger.isInfoEnabled()) {
                logger.info("[jade] found " + dfs.size() + " beanDefinition from '" + url + "'");
            }
            for (BeanDefinition beanDefinition : dfs) {
                String daoClassName = beanDefinition.getBeanClassName();

                if (isDisable(daoClassName)) {
                    if (logger.isDebugEnabled()) {
                        logger.debug(
                                "[jade] ignored disabled jade dao class: " + daoClassName + "  [" + url + "]");
                    }
                    continue;
                }

                if (daoClassNames.contains(daoClassName)) {
                    if (logger.isDebugEnabled()) {
                        logger.debug("[jade] ignored replicated jade dao class: " + daoClassName + "  [" + url
                                + "]");
                    }
                    continue;
                }
                daoClassNames.add(daoClassName);

                MutablePropertyValues propertyValues = beanDefinition.getPropertyValues();
                propertyValues.addPropertyValue("DAOClass", daoClassName);
                ScannedGenericBeanDefinition scannedBeanDefinition = (ScannedGenericBeanDefinition) beanDefinition;
                scannedBeanDefinition.setPropertyValues(propertyValues);
                scannedBeanDefinition.setBeanClass(DAOFactoryBean.class);

                DefaultListableBeanFactory defaultBeanFactory = (DefaultListableBeanFactory) beanFactory;
                defaultBeanFactory.registerBeanDefinition(daoClassName, beanDefinition);

                if (logger.isDebugEnabled()) {
                    logger.debug("[jade] register DAO: " + daoClassName);
                }
            }
        }
    }
    if (logger.isInfoEnabled()) {
        logger.info("[jade] exits");
    }
}

From source file:org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.java

@Override
protected void onRefresh() {
    super.onRefresh();
    try {/*w  w  w .j a va2s .com*/
        createEmbeddedServletContainer();
    } catch (Throwable ex) {
        throw new ApplicationContextException("Unable to start embedded container", ex);
    }
}

From source file:org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.java

private synchronized void createEmbeddedServletContainer() {
    if (this.embeddedServletContainer == null && getServletContext() == null) {
        EmbeddedServletContainerFactory containerFactory = getEmbeddedServletContainerFactory();
        this.embeddedServletContainer = containerFactory.getEmbeddedServletContainer(getSelfInitializer());
    } else if (getServletContext() != null) {
        try {/*from  w  w w.  ja v  a2  s . c om*/
            getSelfInitializer().onStartup(getServletContext());
        } catch (ServletException ex) {
            throw new ApplicationContextException("Cannot initialize servlet context", ex);
        }
    }
    initPropertySources();
}

From source file:org.springframework.boot.legacy.context.web.NonEmbeddedWebApplicationContext.java

@Override
protected void onRefresh() {
    super.onRefresh();
    try {//from  ww w . ja va 2  s .co m
        initPropertySources();
    } catch (Throwable ex) {
        throw new ApplicationContextException("Unable to start embedded container", ex);
    }
}

From source file:org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.java

@Override
protected void onRefresh() {
    super.onRefresh();
    try {//from   w  w  w.  j  a v  a2  s.  c  om
        createWebServer();
    } catch (Throwable ex) {
        throw new ApplicationContextException("Unable to start web server", ex);
    }
}

From source file:org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.java

private void createWebServer() {
    WebServer webServer = this.webServer;
    ServletContext servletContext = getServletContext();
    if (webServer == null && servletContext == null) {
        ServletWebServerFactory factory = getWebServerFactory();
        this.webServer = factory.getWebServer(getSelfInitializer());
    } else if (servletContext != null) {
        try {//  w  w  w.j av a2s  . c  o m
            getSelfInitializer().onStartup(servletContext);
        } catch (ServletException ex) {
            throw new ApplicationContextException("Cannot initialize servlet context", ex);
        }
    }
    initPropertySources();
}