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:org.pentaho.platform.plugin.services.pluginmgr.DefaultPluginManager.java

public IAction getAction(String type, String perspectiveName) {
    IAction action = null;/*from w  ww.j  a  va  2  s . c  o m*/
    String beanId = (perspectiveName == null) ? type : type + "." + perspectiveName; //$NON-NLS-1$
    try {
        action = (IAction) getBean(beanId, IAction.class);
    } catch (NoSuchBeanDefinitionException e) {
        // fallback condition, look for a type agnostic content generator
        try {
            action = (IAction) getBean(perspectiveName, IAction.class);
        } catch (NoSuchBeanDefinitionException e2) {
            throw new NoSuchBeanDefinitionException(
                    "Failed to find bean: " + e.getMessage() + " : " + e2.getMessage());
        }
    }
    return action;
}

From source file:org.pentaho.platform.web.http.api.resources.FileResource.java

/**
 * Determines whether a selected file supports parameters or not
 *
 * @param pathId Colon separated path for the repository file.
 *
 * @return ("true" or "false")/*from  ww  w  .j av a  2  s . com*/
 * @throws FileNotFoundException
 */
@GET
@Path("{pathId : .+}/parameterizable")
@Produces(TEXT_PLAIN)
@Facet(name = "Unsupported")
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully get the file or directory."),
        @ResponseCode(code = 404, condition = "Failed to find the file or resource.") })

// have to accept anything for browsers to work
public String doIsParameterizable(@PathParam("pathId") String pathId) throws FileNotFoundException {
    boolean hasParameterUi = false;
    RepositoryFile repositoryFile = getRepository().getFile(fileService.idToPath(pathId));
    if (repositoryFile != null) {
        try {
            hasParameterUi = hasParameterUi(repositoryFile);
        } catch (NoSuchBeanDefinitionException e) {
            // Do nothing.
        }
    }
    boolean hasParameters = false;
    if (hasParameterUi) {
        try {
            IContentGenerator parameterContentGenerator = getContentGenerator(repositoryFile);
            if (parameterContentGenerator != null) {
                ByteArrayOutputStream outputStream = getByteArrayOutputStream();
                parameterContentGenerator.setOutputHandler(new SimpleOutputHandler(outputStream, false));
                parameterContentGenerator.setMessagesList(new ArrayList<String>());

                Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();

                SimpleParameterProvider parameterProvider = getSimpleParameterProvider();
                parameterProvider.setParameter("path", encode(repositoryFile.getPath()));
                parameterProvider.setParameter("renderMode", "PARAMETER");
                parameterProviders.put(IParameterProvider.SCOPE_REQUEST, parameterProvider);

                parameterContentGenerator.setParameterProviders(parameterProviders);
                parameterContentGenerator.setSession(getSession());
                parameterContentGenerator.createContent();

                if (outputStream.size() > 0) {
                    Document document = parseText(outputStream.toString());

                    // exclude all parameters that are of type "system", xactions set system params that have to be ignored.
                    @SuppressWarnings("rawtypes")
                    List nodes = document.selectNodes("parameters/parameter");
                    for (int i = 0; i < nodes.size() && !hasParameters; i++) {
                        Element elem = (Element) nodes.get(i);
                        if (elem.attributeValue("name").equalsIgnoreCase("output-target")
                                && elem.attributeValue("is-mandatory").equalsIgnoreCase("true")) {
                            hasParameters = true;
                            continue;
                        }
                        Element attrib = (Element) elem
                                .selectSingleNode("attribute[@namespace='http://reporting.pentaho"
                                        + ".org/namespaces/engine/parameter-attributes/core' and @name='role']");
                        if (attrib == null || !"system".equals(attrib.attributeValue("value"))) {
                            hasParameters = true;
                        }
                    }
                }
            }
        } catch (Exception e) {
            logger.error(getMessagesInstance().getString("FileResource.PARAM_FAILURE", e.getMessage()), e);
        }
    }
    return Boolean.toString(hasParameters);
}

From source file:org.springframework.integration.config.annotation.AbstractMethodAnnotationPostProcessor.java

@Override
public Object postProcess(Object bean, String beanName, Method method, List<Annotation> annotations) {
    if (this.beanAnnotationAware() && AnnotatedElementUtils.isAnnotated(method, Bean.class.getName())) {
        try {/*  w w  w.  jav  a 2s. co  m*/
            resolveTargetBeanFromMethodWithBeanAnnotation(method);
        } catch (NoSuchBeanDefinitionException e) {
            if (this.logger.isDebugEnabled()) {
                this.logger.debug("Skipping endpoint creation; " + e.getMessage()
                        + "; perhaps due to some '@Conditional' annotation.");
            }
            return null;
        }
    }

    List<Advice> adviceChain = extractAdviceChain(beanName, annotations);

    MessageHandler handler = createHandler(bean, method, annotations);

    if (!CollectionUtils.isEmpty(adviceChain) && handler instanceof AbstractReplyProducingMessageHandler) {
        ((AbstractReplyProducingMessageHandler) handler).setAdviceChain(adviceChain);
    }

    if (handler instanceof Orderable) {
        Order orderAnnotation = AnnotationUtils.findAnnotation(method, Order.class);
        if (orderAnnotation != null) {
            ((Orderable) handler).setOrder(orderAnnotation.value());
        }
    }
    if (handler instanceof AbstractMessageProducingHandler || handler instanceof AbstractMessageRouter) {
        String sendTimeout = MessagingAnnotationUtils.resolveAttribute(annotations, "sendTimeout",
                String.class);
        if (sendTimeout != null) {
            Long value = Long.valueOf(this.beanFactory.resolveEmbeddedValue(sendTimeout));
            if (handler instanceof AbstractMessageProducingHandler) {
                ((AbstractMessageProducingHandler) handler).setSendTimeout(value);
            } else {
                ((AbstractMessageRouter) handler).setSendTimeout(value);
            }
        }
    }

    boolean handlerExists = false;
    if (this.beanAnnotationAware() && AnnotatedElementUtils.isAnnotated(method, Bean.class.getName())) {
        Object handlerBean = this.resolveTargetBeanFromMethodWithBeanAnnotation(method);
        handlerExists = handlerBean != null && handler == handlerBean;
    }

    if (!handlerExists) {
        String handlerBeanName = generateHandlerBeanName(beanName, method);
        this.beanFactory.registerSingleton(handlerBeanName, handler);
        handler = (MessageHandler) this.beanFactory.initializeBean(handler, handlerBeanName);
    }

    if (AnnotatedElementUtils.isAnnotated(method, IdempotentReceiver.class.getName())
            && !AnnotatedElementUtils.isAnnotated(method, Bean.class.getName())) {
        String[] interceptors = AnnotationUtils.getAnnotation(method, IdempotentReceiver.class).value();
        for (String interceptor : interceptors) {
            DefaultBeanFactoryPointcutAdvisor advisor = new DefaultBeanFactoryPointcutAdvisor();
            advisor.setAdviceBeanName(interceptor);
            NameMatchMethodPointcut pointcut = new NameMatchMethodPointcut();
            pointcut.setMappedName("handleMessage");
            advisor.setPointcut(pointcut);
            advisor.setBeanFactory(this.beanFactory);

            if (handler instanceof Advised) {
                ((Advised) handler).addAdvisor(advisor);
            } else {
                ProxyFactory proxyFactory = new ProxyFactory(handler);
                proxyFactory.addAdvisor(advisor);
                handler = (MessageHandler) proxyFactory.getProxy(this.beanFactory.getBeanClassLoader());
            }
        }
    }

    if (!CollectionUtils.isEmpty(adviceChain)) {
        for (Advice advice : adviceChain) {
            if (advice instanceof HandleMessageAdvice) {
                NameMatchMethodPointcutAdvisor handlerAdvice = new NameMatchMethodPointcutAdvisor(advice);
                handlerAdvice.addMethodName("handleMessage");
                if (handler instanceof Advised) {
                    ((Advised) handler).addAdvisor(handlerAdvice);
                } else {
                    ProxyFactory proxyFactory = new ProxyFactory(handler);
                    proxyFactory.addAdvisor(handlerAdvice);
                    handler = (MessageHandler) proxyFactory.getProxy(this.beanFactory.getBeanClassLoader());
                }
            }
        }
    }

    AbstractEndpoint endpoint = createEndpoint(handler, method, annotations);
    if (endpoint != null) {
        return endpoint;
    }
    return handler;
}

From source file:org.unitime.timetable.export.ExportServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    ExportServletHelper helper = null;//from  w  ww .ja v a  2s  .co m
    String ref = null;
    try {
        helper = new ExportServletHelper(request, response, getSessionContext());

        ref = helper.getParameter("output");
        if (ref == null) {
            sLog.info("No exporter provided.");
            response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                    "No exporter provided, please set the output parameter.");
            return;
        }

        getExporter(ref).export(helper);
    } catch (NoSuchBeanDefinitionException e) {
        sLog.info("Exporter " + ref + " not known.");
        response.sendError(HttpServletResponse.SC_BAD_REQUEST,
                "Exporter " + ref + " not known, please check the output parameter.");
    } catch (IllegalArgumentException e) {
        sLog.info(e.getMessage());
        response.sendError(HttpServletResponse.SC_BAD_REQUEST, e.getMessage());
    } catch (PageAccessException e) {
        sLog.info(e.getMessage());
        response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage());
    } catch (Exception e) {
        sLog.warn(e.getMessage(), e);
        response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
    } finally {
        if (helper != null) {
            if (helper.hasOutputStream()) {
                helper.getOutputStream().flush();
                helper.getOutputStream().close();
            }
            if (helper.hasWriter()) {
                helper.getWriter().flush();
                helper.getWriter().close();
            }
        }
    }
}