Example usage for java.lang ClassFormatError getMessage

List of usage examples for java.lang ClassFormatError getMessage

Introduction

In this page you can find the example usage for java.lang ClassFormatError getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.ocpsoft.pretty.faces.el.LazyBeanNameFinder.java

/**
 * Creates a new {@link LazyBeanNameFinder}. The constructor will find all implementations of
 * {@link ELBeanNameResolver} by using the {@link ServiceLoader} mechanism.
 * /*from  w ww  . ja  v a 2 s.c  o m*/
 * @param servletContext The servlet context
 */
public LazyBeanNameFinder(ServletContext servletContext) {

    // we use the context classloader
    ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

    // fallback, if no context classloader exists
    if (classLoader == null) {
        classLoader = this.getClass().getClassLoader();
    }

    // find resolvers via ServiceLoader
    @SuppressWarnings("unchecked")
    Iterator<BeanNameResolver> beanNameFinderIterator = ServiceLoader.load(BeanNameResolver.class).iterator();

    // call init() method on all resolvers
    while (beanNameFinderIterator.hasNext()) {

        // log resolver name
        BeanNameResolver resolver = beanNameFinderIterator.next();
        if (log.isTraceEnabled()) {
            log.trace("Initializing BeanNameResolver: " + resolver.getClass().getName());
        }

        try {
            resolvers.add(resolver);
        } catch (ClassFormatError e) {
            /*
             * Seems to happen for CDI classes when using GWT
             * In this case just ignore the resolver
             * See: http://code.google.com/p/prettyfaces/issues/detail?id=101
             */
            log.warn("Failed to initialize " + resolver.getClass().getSimpleName() + ": " + e.getMessage());
        }
    }
}