List of usage examples for org.springframework.beans.factory BeanInitializationException BeanInitializationException
public BeanInitializationException(String msg, Throwable cause)
From source file:com.github.tddts.jet.util.SpringUtil.java
/** * Checks if given bean is a dynamic proxy and if it is so returns actual bean behind proxy and it's type. * * @param bean bean object/* w ww.java 2 s.c o m*/ * @return pair containing of bean and it's class * @throws BeanInitializationException in case of any exception */ public static Pair<Class<?>, Object> checkForDinamicProxy(Object bean) throws BeanInitializationException { try { Class<?> type = bean.getClass(); if (AopUtils.isJdkDynamicProxy(bean)) { Advised advised = (Advised) bean; type = advised.getTargetClass(); bean = advised.getTargetSource().getTarget(); } return Pair.of(type, bean); } catch (Exception e) { throw new BeanInitializationException(e.getMessage(), e); } }
From source file:com.hp.autonomy.frontend.find.core.beanconfiguration.ConfigFileConfiguration.java
@Bean public TextEncryptor textEncryptor() { final FactoryBean<String> passwordFactory = new TextEncryptorPasswordFactory(); final BasicTextEncryptor basicTextEncryptor = new BasicTextEncryptor(); try {/*from w w w. j a va 2s.co m*/ basicTextEncryptor.setPassword(passwordFactory.getObject()); } catch (final Exception e) { throw new BeanInitializationException("Failed to initialize TextEncryptor for some reason", e); } return basicTextEncryptor; }
From source file:com.joel1di1.spring.jndi.initializer.JndIInitializerWithPriority.java
@Override public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { try {/* w ww . j a v a 2 s . c om*/ init(); } catch (NamingException e) { throw new BeanInitializationException("Impossible to bind jndi variable", e); } }
From source file:com.opencredo.service.BookServiceImpl.java
private byte[] loadPngFile(String location) { try {//ww w .j a va 2 s. co m return IOUtils.toByteArray(getApplicationContext().getResource(location).getInputStream()); } catch (IOException e) { throw new BeanInitializationException("unable to load png file '" + location + "'", e); } }
From source file:com.opencredo.service.BookServiceImpl.java
private URL toUrl(String website) { try {//from w w w.j a v a 2 s. c o m return new URL(website); } catch (MalformedURLException e) { throw new BeanInitializationException("unable to create URL '" + website + "'", e); } }
From source file:org.jtwig.mvc.JtwigView.java
@Override protected void initApplicationContext() throws BeansException { super.initApplicationContext(); GenericServlet servlet = getGenericServlet(); try {/*from www. j ava2s .co m*/ servlet.init(getServletConfig()); } catch (ServletException ex) { throw new BeanInitializationException("Initialization of GenericServlet adapter failed", ex); } }
From source file:org.n52.aviation.aviationfx.spring.LifecycleBeanPostProcessor.java
@Override public Object postProcessAfterInitialization(Object bean, String beanName) { if (bean instanceof Constructable) { try {/* www . j a va2s.c om*/ ((Constructable) bean).construct(); } catch (Throwable t) { throw new BeanInitializationException("Couldn't counstruct bean " + beanName, t); } } return bean; }
From source file:org.n52.iceland.config.spring.ConfiguringBeanPostProcessor.java
/** * Configures the {@code bean} using the settings service. * * @param bean the bean instance//w w w . j a v a 2 s.c o m * @param beanName the bean name * * @return the bean * * @throws BeanInitializationException if the configuration fails */ @Override public Object postProcessBeforeInitialization(Object bean, String beanName) { try { this.settingsService.configure(bean); } catch (Throwable t) { throw new BeanInitializationException("Couldn't set settings on bean " + beanName, t); } return bean; }
From source file:com.github.tddts.jet.config.spring.postprocessor.LoadContentAnnotationBeanPostProcessor.java
@Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { Pair<Class<?>, Object> typeObjectPair = SpringUtil.checkForDinamicProxy(bean); Class<?> type = typeObjectPair.getLeft(); Object target = typeObjectPair.getRight(); try {// w w w . jav a 2s . com for (Field field : type.getDeclaredFields()) { if (field.isAnnotationPresent(LoadContent.class) && String.class.equals(field.getType())) { field.setAccessible(true); String fileName = getFileName(target, field); if (!StringUtils.isEmpty(fileName)) { field.set(target, Util.loadContent(fileName)); } } } } catch (Exception e) { throw new BeanInitializationException(e.getMessage(), e); } return bean; }
From source file:com.coinblesk.server.config.SecurityConfig.java
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) { try {/*w ww.j a v a2 s . c o m*/ auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder); } catch (Exception e) { throw new BeanInitializationException("Security configuration failed", e); } }