use of org.springframework.beans.factory.BeanCreationException in project cas by apereo.
the class DuoSecurityAuthenticationEventExecutionPlanConfiguration method duoAuthenticationHandler.
@RefreshScope
@Bean
public AuthenticationHandler duoAuthenticationHandler() {
final List<DuoSecurityMultifactorProperties> duos = casProperties.getAuthn().getMfa().getDuo();
if (duos.isEmpty()) {
throw new BeanCreationException("No configuration/settings could be found for Duo Security. Review settings and ensure the correct syntax is used");
}
final String name = duos.get(0).getName();
if (duos.size() > 1) {
LOGGER.debug("Multiple Duo Security providers are available; Duo authentication handler is named after [{}]", name);
}
final DuoAuthenticationHandler h = new DuoAuthenticationHandler(name, servicesManager, duoPrincipalFactory(), duoMultifactorAuthenticationProvider());
return h;
}
use of org.springframework.beans.factory.BeanCreationException in project dubbo by alibaba.
the class ConfigTest method testMultiProtocolError.
@Test
public void testMultiProtocolError() {
try {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(ConfigTest.class.getPackage().getName().replace('.', '/') + "/multi-protocol-error.xml");
ctx.start();
ctx.stop();
ctx.close();
} catch (BeanCreationException e) {
assertTrue(e.getMessage().contains("Found multi-protocols"));
}
}
use of org.springframework.beans.factory.BeanCreationException in project cas by apereo.
the class MongoDbConnectionFactory method buildMongoDbClient.
private Mongo buildMongoDbClient(final BaseMongoDbProperties mongo) {
if (StringUtils.isNotBlank(mongo.getClientUri())) {
LOGGER.debug("Using MongoDb client URI [{}] to connect to MongoDb instance", mongo.getClientUri());
return buildMongoDbClient(mongo.getClientUri(), buildMongoDbClientOptions(mongo));
}
final String[] serverAddresses = mongo.getHost().split(",");
if (serverAddresses == null || serverAddresses.length == 0) {
throw new BeanCreationException("Unable to build a MongoDb client without any hosts/servers defined");
}
List<ServerAddress> servers = new ArrayList<>();
if (serverAddresses.length > 1) {
LOGGER.debug("Multiple MongoDb server addresses are defined. Ignoring port [{}], " + "assuming ports are defined as part of the address", mongo.getPort());
servers = Arrays.stream(serverAddresses).filter(StringUtils::isNotBlank).map(ServerAddress::new).collect(Collectors.toList());
} else {
final int port = mongo.getPort() > 0 ? mongo.getPort() : DEFAULT_PORT;
LOGGER.debug("Found single MongoDb server address [{}] using port [{}]" + mongo.getHost(), port);
final ServerAddress addr = new ServerAddress(mongo.getHost(), port);
servers.add(addr);
}
final MongoCredential credential = buildMongoCredential(mongo);
return new MongoClient(servers, CollectionUtils.wrap(credential), buildMongoDbClientOptions(mongo));
}
use of org.springframework.beans.factory.BeanCreationException in project cxf by apache.
the class SpringBeansTest method testEndpointWithUndefinedBus.
@Test
public void testEndpointWithUndefinedBus() throws Exception {
try {
new ClassPathXmlApplicationContext("/org/apache/cxf/jaxws/spring/endpoints3.xml").close();
fail("Should have thrown an exception");
} catch (BeanCreationException ex) {
assertEquals("ep2", ex.getBeanName());
assertTrue(ex.getMessage().contains("cxf1"));
}
}
use of org.springframework.beans.factory.BeanCreationException in project openmrs-core by openmrs.
the class Listener method performWebStartOfModules.
public static void performWebStartOfModules(Collection<Module> startedModules, ServletContext servletContext) throws ModuleMustStartException, Exception {
boolean someModuleNeedsARefresh = false;
for (Module mod : startedModules) {
try {
boolean thisModuleCausesRefresh = WebModuleUtil.startModule(mod, servletContext, /* delayContextRefresh */
true);
someModuleNeedsARefresh = someModuleNeedsARefresh || thisModuleCausesRefresh;
} catch (Exception e) {
mod.setStartupErrorMessage("Unable to start module", e);
}
}
if (someModuleNeedsARefresh) {
try {
WebModuleUtil.refreshWAC(servletContext, true, null);
} catch (ModuleMustStartException | BeanCreationException ex) {
// pass this up to the calling method so that openmrs loading stops
throw ex;
} catch (Exception e) {
Throwable rootCause = getActualRootCause(e, true);
if (rootCause != null) {
log.error(MarkerFactory.getMarker("FATAL"), "Unable to refresh the spring application context. Root Cause was:", rootCause);
} else {
log.error(MarkerFactory.getMarker("FATAL"), "nable to refresh the spring application context. Unloading all modules, Error was:", e);
}
try {
WebModuleUtil.shutdownModules(servletContext);
for (Module mod : ModuleFactory.getLoadedModules()) {
// use loadedModules to avoid a concurrentmodificationexception
if (!mod.isCoreModule() && !mod.isMandatory()) {
try {
ModuleFactory.stopModule(mod, true, true);
} catch (Exception t3) {
// just keep going if we get an error shutting down. was probably caused by the module
// that actually got us to this point!
log.trace("Unable to shutdown module:" + mod, t3);
}
}
}
WebModuleUtil.refreshWAC(servletContext, true, null);
} catch (MandatoryModuleException ex) {
// pass this up to the calling method so that openmrs loading stops
throw new MandatoryModuleException(ex.getModuleId(), "Got an error while starting a mandatory module: " + e.getMessage() + ". Check the server logs for more information");
} catch (Exception t2) {
// a mandatory or core module is causing spring to fail to start up. We don't want those
// stopped so we must report this error to the higher authorities
log.warn("caught another error: ", t2);
throw t2;
}
}
}
// (this is to protect servlets/filters that depend on their module's spring xml config being available)
for (Module mod : ModuleFactory.getStartedModules()) {
WebModuleUtil.loadServlets(mod, servletContext);
WebModuleUtil.loadFilters(mod, servletContext);
}
}
Aggregations