Spring Framework ApplicationContextException - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework ApplicationContextException class.

This code example shows how to use the following methods:
		try { 
			return BeanFactoryUtils.beanOfTypeIncludingAncestors(getApplicationContext(), 
					GroovyMarkupConfig.class, true, false).getTemplateEngine(); 
		} 
		catch (NoSuchBeanDefinitionException ex) { 
			throw new ApplicationContextException("Expected a single GroovyMarkupConfig bean in the current " + 
					"Servlet web application context or the parent root context: GroovyMarkupConfigurer is " + 
					"the usual implementation. This bean may have any name.", ex); 
		} 
	} 
 
 
	@Override 
	protected void renderMergedTemplateModel(Map<String, Object> model, 
			HttpServletRequest request, HttpServletResponse response) throws Exception { 
 
		Template template = getTemplate(getUrl()); 
		template.make(model).writeTo(new BufferedWriter(response.getWriter())); 
	} 
 
5
CodeRank
This code example shows how to use the following methods:
			initApplicationContext(context);
		} 
		else { 
			// Ignore reinitialization if same context passed in. 
			if (this.applicationContext != context) {
				throw new ApplicationContextException(
						"Cannot reinitialize with different application context: current one is [" + 
						this.applicationContext + "], passed-in one is [" + context + "]");
			} 
		} 
	} 
 
	/** 
	 * Determine whether this application object needs to run in an ApplicationContext. 
	 * <p>Default is "false". Can be overridden to enforce running in a context 
	 * (i.e. to throw IllegalStateException on accessors if outside a context). 
	 * @see #getApplicationContext 
	 * @see #getMessageSourceAccessor 
	 */ 
	protected boolean isContextRequired() { 
5
CodeRank
This code example shows how to use the following methods:
    @Override 
    protected final Resource[] getConfigResources() {
        try { 
            return getConfigResourcesThrowsIOException(); 
        } catch (IOException e) {
            throw new ApplicationContextException("getConfigResources", e);
        } 
    } 
 
    protected Resource[] getConfigResourcesThrowsIOException() throws IOException {
        return RoseResources.findContextResources(this.scopeValues).toArray(new Resource[0]);
    } 
 
    @Override 
    protected void prepareBeanFactory(ConfigurableListableBeanFactory beanFactory) {
        prepareBeanFactoryByRose(beanFactory);
        super.prepareBeanFactory(beanFactory);
    } 
 
    /** Rose对BeanFactory的特殊处理,必要时可以覆盖这个方法去掉Rose的特有的处理 */ 
3
CodeRank
This code example shows how to use the following methods:
    @Override 
    protected void prepareBeanFactory(ConfigurableListableBeanFactory beanFactory) { 
        try { 
            prepareBeanFactoryByRose(beanFactory); 
        } catch (IOException e) { 
            throw new ApplicationContextException("", e); 
        } 
        super.prepareBeanFactory(beanFactory); 
    } 
 
    /** 
     * Rose对BeanFactory的特殊处理,必要时可以覆盖这个方法去掉Rose的特有的处理 
     *  
     * @throws IOException 
     */ 
    protected void prepareBeanFactoryByRose(ConfigurableListableBeanFactory beanFactory) 
            throws IOException { 
        BeanDefinitionRegistry registry = (BeanDefinitionRegistry) beanFactory; 
        AnnotationConfigUtils.registerAnnotationConfigProcessors(registry); 
 
3
CodeRank
This code example shows how to use the following methods:
     *          if the endpoint could not be registered 
     */ 
    protected void registerEndpoint(String key, Object endpoint) throws BeansException {
        Object mappedEndpoint = endpointMap.get(key);
        if (mappedEndpoint != null) {
            throw new ApplicationContextException("Cannot map endpoint [" + endpoint + "] on registration key [" + key +
                    "]: there's already endpoint [" + mappedEndpoint + "] mapped");
        } 
        if (!lazyInitEndpoints && endpoint instanceof String) {
            String endpointName = (String) endpoint;
            endpoint = resolveStringEndpoint(endpointName);
        } 
        if (endpoint == null) {
            throw new ApplicationContextException("Could not find endpoint for key [" + key + "]");
        } 
        endpointMap.put(key, endpoint);
        if (logger.isDebugEnabled()) { 
            logger.debug("Mapped key [" + key + "] onto endpoint [" + endpoint + "]");
        } 
    } 
4
CodeRank
This code example shows how to use the following methods:
        this.clinic = clinic; 
    } 
 
    public void afterPropertiesSet() throws Exception { 
        if (clinic == null) 
            throw new ApplicationContextException("Must set clinic bean property on " + getClass()); 
    } 
 
    // handlers 
    /** 
     *  
     * Custom handler for welcome 
     *  
     * @param request 
     *            current HTTP request 
     * @param response 
     *            current HTTP response 
     * @return a ModelAndView to render the response 
     */ 
 
4
CodeRank
This code example shows how to use the following methods:
 
    public static Class<?> getVFSWebContextClass() {
        try { 
            return ClassUtils.forName(VFS_APPLICATION_CONTEXT_CLASS_NAME);
        } catch (ClassNotFoundException ex) {
            throw new ApplicationContextException(
                    "Failed to load custom context class [" + VFS_APPLICATION_CONTEXT_CLASS_NAME + "]", ex);
        } 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:
    public void setBasePackage(String...basePackage) {
        try { 
            this.basePackage = basePackage;
            setInitialEntitySet(BasePackageScanner.scanBasePackageForClasses(basePackage));
        } catch(ClassNotFoundException cnfe) {
            throw new ApplicationContextException("Error scanning packages for domain entities: "+ Arrays.toString(basePackage));
        } 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:
			VelocityConfig velocityConfig = BeanFactoryUtils.beanOfTypeIncludingAncestors( 
					getApplicationContext(), VelocityConfig.class, true, false); 
			return velocityConfig.getVelocityEngine(); 
		} 
		catch (NoSuchBeanDefinitionException ex) { 
			throw new ApplicationContextException( 
					"Must define a single VelocityConfig bean in this web application context " + 
					"(may be inherited): VelocityConfigurer is the usual implementation. " + 
					"This bean may be given any name.", ex); 
		} 
	} 
 
	/** 
	 * Check that the Velocity template used for this view exists and is valid. 
	 * <p>Can be overridden to customize the behavior, for example in case of 
	 * multiple templates to be rendered into a single view. 
	 */ 
	@Override 
	public boolean checkResource(Locale locale) throws Exception { 
		try { 
4
CodeRank
This code example shows how to use the following methods:
	private static ApplicationContext getApplicationContext()
	{ 
		ApplicationContext applicationContext = ApplicationContextProvider.getApplicationContext();
		if (applicationContext == null)
		{ 
			throw new RuntimeException(new ApplicationContextException("missing required application context"));
		} 
		return applicationContext;
	} 
} 
4
CodeRank
This code example shows how to use the following methods:
		try { 
			Resource resource = getApplicationContext().getResource(url); 
			return new StreamSource(resource.getInputStream(), resource.getURI().toASCIIString()); 
		} 
		catch (IOException ex) { 
			throw new ApplicationContextException("Can't load XSLT stylesheet from '" + url + "'", ex); 
		} 
	} 
 
	/** 
	 * Close the underlying resource managed by the supplied {@link Source} if applicable. 
	 * <p>Only works for {@link StreamSource StreamSources}. 
	 * @param source the XSLT Source to close (may be {@code null}) 
	 */ 
	private void closeSourceIfNecessary(Source source) { 
		if (source instanceof StreamSource) { 
			StreamSource streamSource = (StreamSource) source; 
			if (streamSource.getReader() != null) { 
				try { 
					streamSource.getReader().close(); 
4
CodeRank