Example usage for org.springframework.beans.factory NoSuchBeanDefinitionException getMessage

List of usage examples for org.springframework.beans.factory NoSuchBeanDefinitionException getMessage

Introduction

In this page you can find the example usage for org.springframework.beans.factory NoSuchBeanDefinitionException getMessage.

Prototype

@Override
@Nullable
public String getMessage() 

Source Link

Document

Return the detail message, including the message from the nested exception if there is one.

Usage

From source file:com.l2jfree.L2Registry.java

/**
 * Retrieve a bean from registry//from ww  w.j  ava  2s  . c o  m
 * @param bean - the bean name
 * @return the Object
 */
public static Object getBean(String bean) {
    if (__ctx == null) {
        _log.fatal("Registry was not initialized.");
        return null;
    }
    try {
        Object o = __ctx.getBean(bean);
        return o;
    } catch (NoSuchBeanDefinitionException e) {
        _log.fatal("No such bean (" + bean + ") in context." + e.getMessage(), e);
        return null;
    } catch (BeansException e) {
        _log.fatal("Unable to load bean : " + bean + " = " + e.getMessage(), e);
        return null;
    }

}

From source file:it.cosenonjaviste.alfresco.annotations.processors.runtime.AbstractPostProcessorConfigurer.java

public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
    String[] beanDefinitionNames = beanFactory.getBeanDefinitionNames();
    for (String definitionName : beanDefinitionNames) {
        try {/* w w  w .  j  ava 2 s .c o m*/
            final BeanDefinition bd = beanFactory.getBeanDefinition(definitionName);
            final String beanClassName = bd.getBeanClassName();
            if (StringUtils.hasText(beanClassName)) {
                try {
                    processBeanDefinition(beanFactory, bd, beanClassName, definitionName);
                } catch (Exception e) {
                    logger.error(e.getMessage(), e);
                    throw new FatalBeanException("Unknown class defined.", e);
                }
            }
        } catch (NoSuchBeanDefinitionException ex) {
            logger.warn(ex.getMessage());
            continue;
        }
    }
}

From source file:org.glassfish.jersey.server.spring.AutowiredInjectResolver.java

private Object getBeanFromSpringContext(String beanName, Injectee injectee) {
    try {/*  w w  w.ja  v a 2s .c o  m*/
        DependencyDescriptor dependencyDescriptor = createSpringDependencyDescriptor(injectee);
        Set<String> autowiredBeanNames = new HashSet<String>(1);
        autowiredBeanNames.add(beanName);
        return ctx.getAutowireCapableBeanFactory().resolveDependency(dependencyDescriptor, null,
                autowiredBeanNames, null);
    } catch (NoSuchBeanDefinitionException e) {
        LOGGER.warning(e.getMessage());
        throw e;
    }
}

From source file:org.jahia.modules.external.modules.ModulesExportJob.java

@Override
public void executeJahiaJob(JobExecutionContext jobExecutionContext) throws Exception {
    if (ModulesListener.getInstance() != null) {
        synchronized (modules) {
            try {
                final ModulesImportExportHelper helper = (ModulesImportExportHelper) SpringContextSingleton
                        .getBean("ModulesImportExportHelper");
                if (!modules.isEmpty()) {
                    helper.regenerateImportFiles(modules);
                    modules.clear();//w  ww. j  av a 2s  .  co  m
                }
            } catch (NoSuchBeanDefinitionException e) {
                logger.error("Cannot get ModulesImportExportHelper " + e.getMessage());
            }
        }
    }
}

From source file:nl.jeslee.jersey.server.spring.AutowiredInjectResolver.java

private Object getBeanFromSpringContext(String beanName, Injectee injectee, final boolean required) {
    try {/* www . ja  v  a2  s.  c om*/
        DependencyDescriptor dependencyDescriptor = createSpringDependencyDescriptor(injectee);
        Set<String> autowiredBeanNames = new HashSet<>(1);
        autowiredBeanNames.add(beanName);
        return ctx.getAutowireCapableBeanFactory().resolveDependency(dependencyDescriptor, null,
                autowiredBeanNames, null);
    } catch (NoSuchBeanDefinitionException e) {
        if (required) {
            LOGGER.warning(e.getMessage());
            throw e;
        }
        return null;
    }
}

From source file:org.jasig.portlet.calendar.mvc.CalendarHelper.java

public Set<CalendarDisplayEvent> getEventList(final List<String> errors, final Interval interval,
        final PortletRequest request) {

    final PortletSession session = request.getPortletSession();

    /*//from w  w  w.  j a  v a 2  s . c  o  m
     * Retrieve the calendar configurations defined for this user request
     * and sort them by display name.  This sorting operation ensures that
     * the CSS color indices assigned to calendar events will be consistent
     * with the colors assigned in the main controller.
     */

    // retrieve the calendars defined for this portlet instance
    CalendarSet<?> set = calendarSetDao.getCalendarSet(request);
    List<CalendarConfiguration> calendars = new ArrayList<CalendarConfiguration>();
    calendars.addAll(set.getConfigurations());

    // sort the calendars
    Collections.sort(calendars, new CalendarConfigurationByNameComparator());

    // get the list of hidden calendars
    @SuppressWarnings("unchecked")
    HashMap<Long, String> hiddenCalendars = (HashMap<Long, String>) session.getAttribute("hiddenCalendars");

    /*
     * For each unhidden calendar, get the list of associated events for
     * the requested time period.
     */

    // get the user's configured time zone
    String timezone = (String) session.getAttribute("timezone");
    DateTimeZone tz = DateTimeZone.forID(timezone);
    Set<CalendarDisplayEvent> events = new TreeSet<CalendarDisplayEvent>();

    for (CalendarConfiguration callisting : calendars) {
        // don't bother to fetch hidden calendars
        if (hiddenCalendars.get(callisting.getId()) == null) {
            try {
                // get an instance of the adapter for this calendar
                ICalendarAdapter adapter = (ICalendarAdapter) applicationContext
                        .getBean(callisting.getCalendarDefinition().getClassName());
                events.addAll(calendarEventsDao.getEvents(adapter, callisting, interval, request, tz));
            } catch (NoSuchBeanDefinitionException ex) {
                log.error("Calendar class instance could not be found: " + ex.getMessage());
            } catch (UserFeedbackCalendarException sce) {
                // This CalendarException subclass carries a payload for the UI...
                StringBuilder msg = new StringBuilder();
                msg.append(callisting.getCalendarDefinition().getName()).append(":  ")
                        .append(sce.getUserFeedback());
                errors.add(msg.toString());
            } catch (Exception ex) {
                log.warn("Unknown Error", ex);
                errors.add("The calendar \"" + callisting.getCalendarDefinition().getName()
                        + "\" is currently unavailable.");
            }
        }
    }
    return events;
}

From source file:com.aol.advertising.qiao.bootstrap.Bootstrap.java

@SuppressWarnings("unchecked")
protected <A> A getBean(String className) throws ClassNotFoundException {
    logger.info("loading " + className + "...");
    Object o = null;//from w w  w. j  a v a 2  s. co m
    try {
        o = ContextUtils.loadClass(className);
    } catch (NoSuchBeanDefinitionException e) {
        logger.info(e.getMessage());
    }

    if (o == null) {
        logger.info("Instantiate the class " + className + " since no such spring bean defined");
        Class<?> clz = Class.forName(className);
        try {
            o = clz.newInstance();
        } catch (Exception e) {
            throw new RuntimeException("Failed to instantiate class " + className);
        }
    }

    return (A) o;
}