Package org.springframework.context

Examples of org.springframework.context.ApplicationContextException


                LogUtils.log(LOG, Level.INFO, "USER_CFG_FILE_IN_USE", cfgFile);
            } else {
                if (!usingDefault) {
                    LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_NOT_LOADED", cfgFile);
                    String message = (new Message("USER_CFG_FILE_NOT_LOADED", LOG, cfgFile)).toString();
                    throw new ApplicationContextException(message);
                }
            }
        }
           
        if (null != cfgFileURLs) {
View Full Code Here


     * @throws BeansException if the endpoint could not be registered
     */
    protected void registerEndpoint(T key, MethodEndpoint 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 (endpoint == null) {
            throw new ApplicationContextException("Could not find endpoint for key [" + key + "]");
        }
        endpointMap.put(key, endpoint);
        if (logger.isDebugEnabled()) {
            logger.debug("Mapped [" + key + "] onto endpoint [" + endpoint + "]");
        }
View Full Code Here

     *          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 + "]");
        }
View Full Code Here

    protected final void initApplicationContext() throws BeansException {
        super.initApplicationContext();
        for (String key : temporaryEndpointMap.keySet()) {
            Object endpoint = temporaryEndpointMap.get(key);
            if (!validateLookupKey(key)) {
                throw new ApplicationContextException("Invalid key [" + key + "] for endpoint [" + endpoint + "]");
            }
            registerEndpoint(key, endpoint);
        }
        temporaryEndpointMap = null;
        if (registerBeanNames) {
View Full Code Here

            log.info("Using Heroku, parsing their $DATABASE_URL to use it with JDBC");
            URI dbUri = null;
            try {
                dbUri = new URI(herokuUrl);
            } catch (URISyntaxException e) {
                throw new ApplicationContextException("Heroku database connection pool is not configured correctly");
            }
            String username = dbUri.getUserInfo().split(":")[0];
            String password = dbUri.getUserInfo().split(":")[1];
            String dbUrl = "jdbc:postgresql://" +
                    dbUri.getHost() +
                    ':' +
                    dbUri.getPort() +
                    dbUri.getPath() +
                    "?ssl=true&sslfactory=org.postgresql.ssl.NonValidatingFactory";

            HikariConfig config = new HikariConfig();
            config.setDataSourceClassName(propertyResolver.getProperty("dataSourceClassName"));
            config.addDataSourceProperty("url", dbUrl);
            config.addDataSourceProperty("user", username);
            config.addDataSourceProperty("password", password);
            return new HikariDataSource(config);
        } else {
            throw new ApplicationContextException("Heroku database URL is not configured, you must set --spring.datasource.heroku-url=$DATABASE_URL");
        }
    }
View Full Code Here

          } else if (attr.isRegularFile()) {
            foundFiles.add(new File(file, attr));
          }
        }
    } catch (IOException | DirectoryIteratorException e) {
      throw new ApplicationContextException("Couldn't read " + dir.getPath(), e);
    }
   
    return content;
  }
View Full Code Here

                LogUtils.log(LOG, Level.INFO, "USER_CFG_FILE_IN_USE", cfgFile);
            } else {
                if (!usingDefault) {
                    LogUtils.log(LOG, Level.WARNING, "USER_CFG_FILE_NOT_LOADED", cfgFile);
                    String message = (new Message("USER_CFG_FILE_NOT_LOADED", LOG, cfgFile)).toString();
                    throw new ApplicationContextException(message);
                }
            }
        }
           
        if (null != cfgFileURLs) {
View Full Code Here

        if (!StringUtils.hasText(name)) {
            Map<String,?> beans = getBeansOfType(AuthenticationUserDetailsService.class);

            if (!beans.isEmpty()) {
                if (beans.size() > 1) {
                    throw new ApplicationContextException("More than one AuthenticationUserDetailsService registered." +
                            " Please use a specific Id reference.");
                }
                return (AuthenticationUserDetailsService) beans.values().toArray()[0];
            }

            uds = getUserDetailsService();
        } else {
            Object bean = beanFactory.getBean(name);

            if (bean instanceof AuthenticationUserDetailsService) {
                return (AuthenticationUserDetailsService)bean;
            } else if (bean instanceof UserDetailsService) {
                uds = cachingUserDetailsService(name);

                if (uds == null) {
                    uds = (UserDetailsService)bean;
                }
            } else {
                throw new ApplicationContextException("Bean '" + name + "' must be a UserDetailsService or an" +
                        " AuthenticationUserDetailsService");
            }
        }

        return new UserDetailsByNameServiceWrapper(uds);
View Full Code Here

        if (beans.size() == 0) {
            beans = getBeansOfType(UserDetailsService.class);
        }

        if (beans.size() == 0) {
            throw new ApplicationContextException("No UserDetailsService registered.");

        } else if (beans.size() > 1) {
            throw new ApplicationContextException("More than one UserDetailsService registered. Please " +
                    "use a specific Id reference in <remember-me/> <openid-login/> or <x509 /> elements.");
        }

        return (UserDetailsService) beans.values().toArray()[0];
    }
View Full Code Here

        Class<?> contextSourceClass;

        try {
            contextSourceClass = ClassUtils.forName(REQUIRED_CONTEXT_SOURCE_CLASS_NAME, ClassUtils.getDefaultClassLoader());
        } catch (ClassNotFoundException e) {
            throw new ApplicationContextException("Couldn't locate: " + REQUIRED_CONTEXT_SOURCE_CLASS_NAME + ". " +
                    " If you are using LDAP with Spring Security, please ensure that you include the spring-ldap " +
                    "jar file in your application", e);
        }

        String[] sources = bf.getBeanNamesForType(contextSourceClass, false, false);

        if (sources.length == 0) {
            throw new ApplicationContextException("No BaseLdapPathContextSource instances found. Have you " +
                    "added an <" + Elements.LDAP_SERVER + " /> element to your application context? If you have " +
                    "declared an explicit bean, do not use lazy-init");
        }

        if (!bf.containsBean(BeanIds.CONTEXT_SOURCE) && defaultNameRequired) {
            if (sources.length > 1) {
                throw new ApplicationContextException("More than one BaseLdapPathContextSource instance found. " +
                        "Please specify a specific server id using the 'server-ref' attribute when configuring your <" +
                        Elements.LDAP_PROVIDER + "> " + "or <" + Elements.LDAP_USER_SERVICE + ">.");
            }

            bf.registerAlias(sources[0], BeanIds.CONTEXT_SOURCE);
View Full Code Here

TOP

Related Classes of org.springframework.context.ApplicationContextException

Copyright © 2018 www.massapicom. 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.