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

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

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.thinkbiganalytics.metadata.sla.alerts.ServiceLevelAgreementActionUtil.java

public static ServiceLevelAgreementAction instantiate(Class<? extends ServiceLevelAgreementAction> clazz) {
    ServiceLevelAgreementAction action = null;
    try {/*from w  w  w.j ava2  s.c o  m*/
        action = SpringApplicationContext.getBean(clazz);
    } catch (NoSuchBeanDefinitionException e) {
        //this is ok
    }

    //if not spring bound then construct the Responder
    if (action == null) {
        //construct and invoke
        try {
            action = ConstructorUtils.invokeConstructor(clazz, null);
        } catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException
                | InstantiationException e) {
            //TODO LOG error
            e.printStackTrace();
        }
    }
    return action;
}

From source file:cr.ac.siua.tec.services.impl.ExportServiceImpl.java

/**
 * In charge of retreving the base64 String (encoded PDF) for the requested ticket.
 *//* www  . j  av a  2  s .c  om*/
public String getPDF(HashMap<String, String> ticketContent) {
    String formType = ticketContent.get("Queue");
    try {
        //It uses the factory pattern to invoke the form's corresponding export method.
        String pdfContent = pdfGeneratorFactory.getPDFGenerator(formType).generate(ticketContent);
        return pdfContent;
    } catch (NoSuchBeanDefinitionException e) {
        e.printStackTrace();
        System.out.println("This queue's ticket export method has not been implemented.");
        return "Not implemented yet.";
    }
}

From source file:org.suren.autotest.web.framework.data.PageRefDynamicData.java

@Override
public String getValue(String orginData) {
    if (StringUtils.isBlank(orginData)) {
        return null;
    }/*w ww .  j av  a2s .c  o m*/

    String[] orginArrayData = orginData.split("\\.", 2);

    String clsName = orginArrayData[0];
    String fieldName = orginArrayData[1];

    clsName = StringUtils.uncapitalize(clsName); //springbean????

    Page page = null;

    try {
        page = context.getBean(clsName, Page.class);
    } catch (NoSuchBeanDefinitionException e) {
        LOGGER.error("Can not found page class by name [{}].", clsName);
    } catch (BeanNotOfRequiredTypeException e) {
        LOGGER.error("The class [{}] is not a Page type.", clsName);
    }

    if (page == null) {
        throw new RuntimeException("Can not found page class!");
    }

    try {
        Method readMethod = new PropertyDescriptor(fieldName, page.getClass()).getReadMethod();

        Object result = readMethod.invoke(page);
        if (result != null && AbstractElement.class.isAssignableFrom(result.getClass())) {
            if (result instanceof Text) {
                return ((Text) result).getValue();
            } else {
                throw new RuntimeException("Not support field type [" + result.getClass() + "].");
            }
        }
    } catch (IntrospectionException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }

    return null;
}

From source file:ru.savvy.springjsf.system.CustomJsfInjectionProvider.java

private void injectFields(Object bean, Class<? extends Annotation> annotation)
        throws InjectionProviderException {
    // get current WebApplicationContext
    FacesContext fc = FacesContext.getCurrentInstance();
    if (fc == null) {
        throw new InjectionProviderException("Unable to get current Faces context",
                new NullPointerException("Faces context is null"));
    }/* w w  w .j a  va2  s.  c o  m*/
    WebApplicationContext wac = FacesContextUtils.getWebApplicationContext(fc);
    if (wac == null) {
        throw new InjectionProviderException("Unable to get Spring WebApplicationContext",
                new NullPointerException("WebApplicationContext is null"));
    }
    Field[] fields = bean.getClass().getDeclaredFields();
    for (Field f : fields) {
        if (f.getAnnotationsByType(annotation).length > 0) {
            Class<?> typeClazz = f.getType();
            Object injection;
            try {
                injection = wac.getBean(typeClazz);
            } catch (NoSuchBeanDefinitionException e) {
                e.printStackTrace();
                throw new InjectionProviderException("Unable to inject bean of type " + typeClazz.toString(),
                        e);
            }
            if (!f.isAccessible()) {
                f.setAccessible(true);
            }
            try {
                f.set(bean, injection);
                if (logger.isDebugEnabled()) {
                    logger.debug("Injected field of type " + f.getType().getCanonicalName() + " into "
                            + bean.getClass().getCanonicalName());
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }

}