use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project midpoint by Evolveum.
the class WfConfiguration method initialize.
@PostConstruct
void initialize() {
Configuration c = midpointConfiguration.getConfiguration(WF_CONFIG_SECTION);
checkAllowedKeys(c, KNOWN_KEYS, DEPRECATED_KEYS);
enabled = c.getBoolean(KEY_ENABLED, true);
if (!enabled) {
LOGGER.info("Workflows are disabled.");
return;
}
// activiti properties related to database connection will be taken from SQL repository
SqlRepositoryConfiguration sqlConfig = null;
String defaultJdbcUrlPrefix = null;
dropDatabase = false;
try {
RepositoryFactory repositoryFactory = (RepositoryFactory) beanFactory.getBean("repositoryFactory");
if (!(repositoryFactory.getFactory() instanceof SqlRepositoryFactory)) {
// it may be null as well
LOGGER.debug("SQL configuration cannot be found; Activiti database configuration (if any) will be taken from 'workflow' configuration section only");
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("repositoryFactory.getFactory() = " + repositoryFactory);
}
} else {
SqlRepositoryFactory sqlRepositoryFactory = (SqlRepositoryFactory) repositoryFactory.getFactory();
sqlConfig = sqlRepositoryFactory.getSqlConfiguration();
if (sqlConfig.isEmbedded()) {
defaultJdbcUrlPrefix = sqlRepositoryFactory.prepareJdbcUrlPrefix(sqlConfig);
dropDatabase = sqlConfig.isDropIfExists();
}
}
} catch (NoSuchBeanDefinitionException e) {
LOGGER.debug("SqlRepositoryFactory is not available, Activiti database configuration (if any) will be taken from 'workflow' configuration section only.");
LOGGER.trace("Reason is", e);
} catch (RepositoryServiceFactoryException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Cannot determine default JDBC URL for embedded database", e);
}
String explicitJdbcUrl = c.getString(KEY_JDBC_URL, null);
if (explicitJdbcUrl == null) {
if (sqlConfig == null || sqlConfig.isEmbedded()) {
jdbcUrl = defaultJdbcUrlPrefix + "-activiti;DB_CLOSE_ON_EXIT=FALSE;MVCC=FALSE";
} else {
jdbcUrl = sqlConfig.getJdbcUrl();
}
} else {
jdbcUrl = explicitJdbcUrl;
}
dataSource = c.getString(KEY_DATA_SOURCE, null);
if (dataSource == null && explicitJdbcUrl == null && sqlConfig != null) {
// we want to use wf-specific JDBC if there is one (i.e. we do not want to inherit data source from repo in such a case)
dataSource = sqlConfig.getDataSource();
}
if (dataSource != null) {
LOGGER.info("Activiti database is at " + dataSource + " (a data source)");
} else {
LOGGER.info("Activiti database is at " + jdbcUrl + " (a JDBC URL)");
}
boolean defaultSchemaUpdate = sqlConfig == null || "update".equals(sqlConfig.getHibernateHbm2ddl());
activitiSchemaUpdate = c.getBoolean(KEY_ACTIVITI_SCHEMA_UPDATE, defaultSchemaUpdate);
LOGGER.info("Activiti automatic schema update: {}", activitiSchemaUpdate);
jdbcDriver = c.getString(KEY_JDBC_DRIVER, sqlConfig != null ? sqlConfig.getDriverClassName() : null);
jdbcUser = c.getString(KEY_JDBC_USERNAME, sqlConfig != null ? sqlConfig.getJdbcUsername() : null);
jdbcPassword = c.getString(KEY_JDBC_PASSWORD, sqlConfig != null ? sqlConfig.getJdbcPassword() : null);
autoDeploymentFrom = c.getStringArray(KEY_AUTO_DEPLOYMENT_FROM);
if (autoDeploymentFrom.length == 0) {
autoDeploymentFrom = new String[] { AUTO_DEPLOYMENT_FROM_DEFAULT };
}
// hibernateDialect = sqlConfig != null ? sqlConfig.getHibernateDialect() : "";
validate();
}
use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project cloudstack by apache.
the class NetworkStateListener method pubishOnEventBus.
private void pubishOnEventBus(String event, String status, Network vo, State oldState, State newState) {
String configKey = "publish.resource.state.events";
String value = _configDao.getValue(configKey);
boolean configValue = Boolean.parseBoolean(value);
if (!configValue)
return;
try {
s_eventBus = ComponentContext.getComponent(EventBus.class);
} catch (NoSuchBeanDefinitionException nbe) {
// no provider is configured to provide events bus, so just return
return;
}
String resourceName = getEntityFromClassName(Network.class.getName());
org.apache.cloudstack.framework.events.Event eventMsg = new org.apache.cloudstack.framework.events.Event("management-server", EventCategory.RESOURCE_STATE_CHANGE_EVENT.getName(), event, resourceName, vo.getUuid());
Map<String, String> eventDescription = new HashMap<String, String>();
eventDescription.put("resource", resourceName);
eventDescription.put("id", vo.getUuid());
eventDescription.put("old-state", oldState.name());
eventDescription.put("new-state", newState.name());
String eventDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z").format(new Date());
eventDescription.put("eventDateTime", eventDate);
eventMsg.setDescription(eventDescription);
try {
s_eventBus.publish(eventMsg);
} catch (EventBusException e) {
s_logger.warn("Failed to publish state change event on the the event bus.");
}
}
use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project engine by craftercms.
the class AllHttpScopesAndAppContextHashModel method get.
@Override
public TemplateModel get(String key) throws TemplateModelException {
// Lookup in page scope
TemplateModel model = super.get(key);
if (model != null) {
return model;
}
// Lookup in request scope
Object obj = request.getAttribute(key);
if (obj != null) {
return wrap(obj);
}
// Lookup in session scope
HttpSession session = request.getSession(false);
if (session != null) {
obj = session.getAttribute(key);
if (obj != null) {
return wrap(obj);
}
}
// Lookup in application scope
obj = context.getAttribute(key);
if (obj != null) {
return wrap(obj);
}
// Lookup in application context
try {
return wrap(applicationContextAccessor.get(key));
} catch (NoSuchBeanDefinitionException e) {
}
// return wrapper's null object (probably null).
return wrap(null);
}
use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project uPortal by Jasig.
the class LdapServices method getLdapServer.
/**
* Get the {@link ILdapServer} from the portal spring context with the specified name.
*
* @param name The name of the ILdapServer to return.
* @return An {@link ILdapServer} with the specified name, <code>null</code> if there is no
* connection with the specified name.
*/
public static ILdapServer getLdapServer(String name) {
final ApplicationContext applicationContext = PortalApplicationContextLocator.getApplicationContext();
ILdapServer ldapServer = null;
try {
ldapServer = (ILdapServer) applicationContext.getBean(name, ILdapServer.class);
} catch (NoSuchBeanDefinitionException nsbde) {
// Ignore the exception for not finding the named bean.
}
if (LOG.isDebugEnabled()) {
LOG.debug("Found ILdapServer='" + ldapServer + "' for name='" + name + "'");
}
return ldapServer;
}
use of org.springframework.beans.factory.NoSuchBeanDefinitionException in project ignite by apache.
the class IgniteSpringHelperImpl method userVersion.
/**
* {@inheritDoc}
*/
@Override
public String userVersion(ClassLoader ldr, IgniteLogger log) {
assert ldr != null;
assert log != null;
// For system class loader return cached version.
if (ldr == U.gridClassLoader() && SYS_LDR_VER.get() != null)
return SYS_LDR_VER.get();
String usrVer = U.DFLT_USER_VERSION;
InputStream in = ldr.getResourceAsStream(IGNITE_XML_PATH);
if (in != null) {
// Note: use ByteArrayResource instead of InputStreamResource because
// InputStreamResource doesn't work.
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
U.copy(in, out);
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
reader.loadBeanDefinitions(new ByteArrayResource(out.toByteArray()));
usrVer = (String) factory.getBean("userVersion");
usrVer = usrVer == null ? U.DFLT_USER_VERSION : usrVer.trim();
} catch (NoSuchBeanDefinitionException ignored) {
if (log.isInfoEnabled())
log.info("User version is not explicitly defined (will use default version) [file=" + IGNITE_XML_PATH + ", clsLdr=" + ldr + ']');
usrVer = U.DFLT_USER_VERSION;
} catch (BeansException e) {
U.error(log, "Failed to parse Spring XML file (will use default user version) [file=" + IGNITE_XML_PATH + ", clsLdr=" + ldr + ']', e);
usrVer = U.DFLT_USER_VERSION;
} catch (IOException e) {
U.error(log, "Failed to read Spring XML file (will use default user version) [file=" + IGNITE_XML_PATH + ", clsLdr=" + ldr + ']', e);
usrVer = U.DFLT_USER_VERSION;
} finally {
U.close(out, log);
}
}
// For system class loader return cached version.
if (ldr == U.gridClassLoader())
SYS_LDR_VER.compareAndSet(null, usrVer);
return usrVer;
}
Aggregations