Example usage for javax.naming NamingException NamingException

List of usage examples for javax.naming NamingException NamingException

Introduction

In this page you can find the example usage for javax.naming NamingException NamingException.

Prototype

public NamingException(String explanation) 

Source Link

Document

Constructs a new NamingException with an explanation.

Usage

From source file:org.wso2.carbon.deployment.notifier.internal.JMSUtils.java

public static <T> T lookup(Context context, Class<T> clazz, String name) throws NamingException {

    Object object = context.lookup(name);
    try {//  w  w  w  .  ja va  2s . c o m
        return clazz.cast(object);
    } catch (ClassCastException ex) {
        // Instead of a ClassCastException, throw an exception with some
        // more information.
        if (object instanceof Reference) {
            Reference ref = (Reference) object;
            throw new NamingException("JNDI failed to de-reference Reference with name " + name
                    + "; is the factory " + ref.getFactoryClassName() + " in your classpath?");
        } else {
            throw new NamingException("JNDI lookup of name " + name + " returned a "
                    + object.getClass().getName() + " while a " + clazz + " was expected");
        }
    }

}

From source file:org.wso2.carbon.inbound.endpoint.protocol.jms.JMSUtils.java

protected static void handleException(String s) throws NamingException {
    log.error(s);//w ww. ja  va 2  s.  c om
    throw new NamingException(s);
}