List of usage examples for org.springframework.beans.factory NoSuchBeanDefinitionException getBeanName
@Nullable
public String getBeanName()
From source file:info.joseluismartin.gtc.CacheManager.java
public void loadCache(CacheConfig config) { CacheType type = config.getType();//from www . j a v a 2 s .com try { if (type != null) { TileCache cache = (TileCache) applicationContext.getBean(config.getType().getBeanName()); config.setDiskCachePath(systemConfig.getCachePath()); cache.setConfig(config); cacheMap.put(config.getPath(), cache); } } catch (NoSuchBeanDefinitionException e) { log.error("Failed to load cache bean name [" + e.getBeanName() + "]"); } }
From source file:com.griddynamics.banshun.RegistryBeanTest.java
protected void importValidBeanTest(String configLocation) { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(configLocation); assertTrue("have no exports due to laziness", hasNoExports(ctx)); Object proxy = ctx.getBean("early-import"); try {/*w w w . j a v a 2s. com*/ proxy.toString(); fail("attempt to invoke proxy without export should lead to exception"); } catch (NoSuchBeanDefinitionException e) { assertEquals("invoke bean without proper export", "just-bean", e.getBeanName()); } // force export ctx.getBean("export-declaration"); assertSame(proxy, ctx.getBean("early-import")); assertFalse("have export ref", hasExport(ctx, "just-bean")); assertEquals("proxies should refer the same bean instance", proxy.toString(), ctx.getBean("late-import").toString()); assertSame("proxies should be the same instance", proxy, ctx.getBean("late-import")); assertTrue("early import gives us a proxy", proxy instanceof Proxy); assertTrue("late import gives us a proxy", ctx.getBean("late-import") instanceof Proxy); }
From source file:org.archive.crawler.framework.CrawlJob.java
/** * Return a short useful message for common BeansExceptions. * @param ex BeansException// w w w .j a v a 2 s.co m * @return String short descriptive message */ protected String shortMessage(BeansException ex) { if (ex instanceof NoSuchBeanDefinitionException) { NoSuchBeanDefinitionException nsbde = (NoSuchBeanDefinitionException) ex; return "Missing required bean: " + (nsbde.getBeanName() != null ? "\"" + nsbde.getBeanName() + "\" " : "") + (nsbde.getBeanType() != null ? "\"" + nsbde.getBeanType() + "\" " : ""); } if (ex instanceof BeanCreationException) { BeanCreationException bce = (BeanCreationException) ex; return bce.getBeanName() == null ? "" : "Can't create bean '" + bce.getBeanName() + "'"; } return ex.getMessage().replace('\n', ' '); }
From source file:org.kuali.kfs.sys.batch.service.impl.SchedulerServiceImpl.java
/** * Initializes all of the jobs into Quartz for the given ModuleService * @param moduleService the ModuleService implementation to initalize jobs for *//* www . j ava 2s. c o m*/ protected void initializeJobsForModule(ModuleService moduleService) { if (LOG.isInfoEnabled()) { LOG.info("Loading scheduled jobs for: " + moduleService.getModuleConfiguration().getNamespaceCode()); } JobDescriptor jobDescriptor; if (moduleService.getModuleConfiguration().getJobNames() != null) { for (String jobName : moduleService.getModuleConfiguration().getJobNames()) { try { if (moduleService instanceof BatchModuleService && ((BatchModuleService) moduleService).isExternalJob(jobName)) { jobDescriptor = new JobDescriptor(); jobDescriptor.setBeanName(jobName); jobDescriptor.setGroup(SCHEDULED_GROUP); jobDescriptor.setDurable(false); externalizedJobDescriptors.put(jobName, jobDescriptor); } else { jobDescriptor = BatchSpringContext.getJobDescriptor(jobName); } jobDescriptor.setNamespaceCode(moduleService.getModuleConfiguration().getNamespaceCode()); loadJob(jobDescriptor); } catch (NoSuchBeanDefinitionException ex) { LOG.error("unable to find job bean definition for job: " + ex.getBeanName()); } catch (Exception ex) { LOG.error("Unable to install " + jobName + " job into scheduler.", ex); } } } }
From source file:org.kuali.kfs.sys.batch.service.impl.SchedulerServiceImpl.java
/** * Loops through all the triggers associated with the given module service, adding each trigger to Quartz * @param moduleService the ModuleService instance to initialize triggers for *///from ww w. j av a 2 s .co m protected void initializeTriggersForModule(ModuleService moduleService) { if (moduleService.getModuleConfiguration().getTriggerNames() != null) { for (String triggerName : moduleService.getModuleConfiguration().getTriggerNames()) { try { addTrigger(BatchSpringContext.getTriggerDescriptor(triggerName).getTrigger()); } catch (NoSuchBeanDefinitionException ex) { LOG.error("unable to find trigger definition: " + ex.getBeanName()); } catch (Exception ex) { LOG.error("Unable to install " + triggerName + " trigger into scheduler.", ex); } } } }