use of org.springframework.beans.BeansException in project uPortal by Jasig.
the class EhcacheManagerBeanConfigurer method postProcessBeanFactory.
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
final String[] cacheNames = this.cacheManager.getCacheNames();
for (final String cacheName : cacheNames) {
final Ehcache ehcache = this.cacheManager.getEhcache(cacheName);
this.logger.debug("Registering Ehcache '" + cacheName + "' with bean factory");
if (beanFactory.containsBean(cacheName)) {
if (skipDuplicates) {
continue;
}
throw new BeanCreationException("Duplicate Ehcache " + cacheName + " from CacheManager " + cacheManager.getName());
}
try {
beanFactory.registerSingleton(cacheName, ehcache);
} catch (Exception e) {
throw new BeanCreationException("Failed to register Ehcache " + cacheName + " from CacheManager " + cacheManager.getName(), e);
}
}
this.logger.debug("Registered " + cacheNames.length + " Ehcaches with bean factory");
}
use of org.springframework.beans.BeansException in project ignite by apache.
the class CacheJdbcStoreAbstractMultithreadedSelfTest method beforeTestsStarted.
/**
* {@inheritDoc}
*/
@Override
protected void beforeTestsStarted() throws Exception {
store = store();
URL cfgUrl;
try {
cfgUrl = new URL(DFLT_MAPPING_CONFIG);
} catch (MalformedURLException ignore) {
cfgUrl = U.resolveIgniteUrl(DFLT_MAPPING_CONFIG);
}
if (cfgUrl == null)
throw new Exception("Failed to resolve metadata path: " + DFLT_MAPPING_CONFIG);
try {
GenericApplicationContext springCtx = new GenericApplicationContext();
new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(cfgUrl));
springCtx.refresh();
Collection<JdbcType> types = new ArrayList<>(springCtx.getBeansOfType(JdbcType.class).values());
store.setTypes(types.toArray(new JdbcType[types.size()]));
} catch (BeansException e) {
if (X.hasCause(e, ClassNotFoundException.class))
throw new IgniteCheckedException("Failed to instantiate Spring XML application context " + "(make sure all classes used in Spring configuration are present at CLASSPATH) " + "[springUrl=" + cfgUrl + ']', e);
else
throw new IgniteCheckedException("Failed to instantiate Spring XML application context [springUrl=" + cfgUrl + ", err=" + e.getMessage() + ']', e);
}
}
use of org.springframework.beans.BeansException in project ignite by apache.
the class GridCacheAbstractLoadTest method configuration.
/**
* Initializes configurations.
*
* @param springCfgPath Configuration file path.
* @param log Log file name.
* @return Configuration.
* @throws IgniteCheckedException If fails.
*/
protected IgniteConfiguration configuration(String springCfgPath, String log) throws IgniteCheckedException {
File path = GridTestUtils.resolveIgnitePath(springCfgPath);
if (path == null)
throw new IgniteCheckedException("Spring XML configuration file path is invalid: " + new File(springCfgPath) + ". Note that this path should be either absolute path or a relative path to IGNITE_HOME.");
if (!path.isFile())
throw new IgniteCheckedException("Provided file path is not a file: " + path);
// Add no-op logger to remove no-appender warning.
Appender app = new NullAppender();
Logger.getRootLogger().addAppender(app);
ApplicationContext springCtx;
try {
springCtx = new FileSystemXmlApplicationContext(path.toURI().toURL().toString());
} catch (BeansException | MalformedURLException e) {
throw new IgniteCheckedException("Failed to instantiate Spring XML application context: " + e.getMessage(), e);
}
Map cfgMap;
try {
// Note: Spring is not generics-friendly.
cfgMap = springCtx.getBeansOfType(IgniteConfiguration.class);
} catch (BeansException e) {
throw new IgniteCheckedException("Failed to instantiate bean [type=" + IgniteConfiguration.class + ", err=" + e.getMessage() + ']', e);
}
if (cfgMap == null)
throw new IgniteCheckedException("Failed to find a single grid factory configuration in: " + path);
// Remove previously added no-op logger.
Logger.getRootLogger().removeAppender(app);
if (cfgMap.isEmpty())
throw new IgniteCheckedException("Can't find grid factory configuration in: " + path);
else if (cfgMap.size() > 1)
throw new IgniteCheckedException("More than one configuration provided for cache load test: " + cfgMap.values());
IgniteConfiguration cfg = (IgniteConfiguration) cfgMap.values().iterator().next();
cfg.setGridLogger(initLogger(log));
cfg.getTransactionConfiguration().setDefaultTxIsolation(isolation);
cfg.getTransactionConfiguration().setDefaultTxConcurrency(concurrency);
return cfg;
}
use of org.springframework.beans.BeansException in project ignite by apache.
the class IgniteThinClient method loadConfiguration.
/**
* @param springCfgPath Spring configuration file path.
* @return Tuple with grid configuration and Spring application context.
* @throws Exception If failed.
*/
private static IgniteBiTuple<IgniteConfiguration, ? extends ApplicationContext> loadConfiguration(String springCfgPath) throws Exception {
URL url;
try {
url = new URL(springCfgPath);
} catch (MalformedURLException e) {
url = IgniteUtils.resolveIgniteUrl(springCfgPath);
if (url == null) {
throw new IgniteCheckedException("Spring XML configuration path is invalid: " + springCfgPath + ". Note that this path should be either absolute or a relative local file system path, " + "relative to META-INF in classpath or valid URL to IGNITE_HOME.", e);
}
}
GenericApplicationContext springCtx;
try {
springCtx = new GenericApplicationContext();
new XmlBeanDefinitionReader(springCtx).loadBeanDefinitions(new UrlResource(url));
springCtx.refresh();
} catch (BeansException e) {
throw new Exception("Failed to instantiate Spring XML application context [springUrl=" + url + ", err=" + e.getMessage() + ']', e);
}
Map<String, IgniteConfiguration> cfgMap;
try {
cfgMap = springCtx.getBeansOfType(IgniteConfiguration.class);
} catch (BeansException e) {
throw new Exception("Failed to instantiate bean [type=" + IgniteConfiguration.class + ", err=" + e.getMessage() + ']', e);
}
if (cfgMap == null || cfgMap.isEmpty())
throw new Exception("Failed to find ignite configuration in: " + url);
return new IgniteBiTuple<>(cfgMap.values().iterator().next(), springCtx);
}
use of org.springframework.beans.BeansException in project ignite by apache.
the class GridFactorySelfTest method getSpringContext.
/**
* Gets Spring application context by given path.
*
* @param path Spring application context configuration path.
* @return Spring application context.
* @throws IgniteCheckedException If given path or xml-configuration at this path is invalid.
*/
private GenericApplicationContext getSpringContext(String path) throws IgniteCheckedException {
try {
GenericApplicationContext ctx = new GenericApplicationContext();
new XmlBeanDefinitionReader(ctx).loadBeanDefinitions(new UrlResource(U.resolveIgniteUrl(path)));
ctx.refresh();
return ctx;
} catch (BeansException e) {
throw new IgniteCheckedException("Failed to instantiate Spring XML application context: " + e.getMessage(), e);
}
}
Aggregations