Example usage for javax.naming NamingException getMessage

List of usage examples for javax.naming NamingException getMessage

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:be.fedict.hsm.model.security.ApplicationSecurityBean.java

public static ApplicationSecurityBean getInstance() {
    try {// ww w .j av  a  2 s.c om
        InitialContext initialContext = new InitialContext();
        return (ApplicationSecurityBean) initialContext.lookup(JNDI_NAME);
    } catch (NamingException e) {
        throw new RuntimeException("JNDI error: " + e.getMessage(), e);
    }
}

From source file:org.petalslink.dsb.kernel.management.component.JNDIUtil.java

/**
 * Get an object from the given context (under path) and cast it
 * automatically to the given type.//from   w w  w  . java  2 s. c  om
 * 
 * @param <T>
 * @param c
 * @param context
 * @param path
 * @return
 */
public static <T> T getObject(Class<T> c, Context context, String path, String name) {
    T result = null;

    Context ct = getContext(context, path);
    if (ct == null) {
        logger.warn("Can not find a valid context under " + path);
        // throw
    }

    Object o = null;
    try {
        o = ct.lookup(name);
    } catch (NamingException e) {
        logger.warn(e.getMessage());
    }

    if (o == null) {
        logger.debug("Null object under property '" + name + "' path");
        result = null;
    } else {
        // try to cast...
        try {
            result = c.cast(o);
        } catch (ClassCastException e) {
            logger.warn("Can not cast the object of class " + o.getClass().getCanonicalName() + " to "
                    + c.getCanonicalName());
        }
    }

    return result;
}

From source file:org.pepstock.jem.jppf.JPPFUtil.java

/**
 * Try to load JPPF configuration from data description
 * @param ic JNDI initial context to get input stream
 * @return JPPF properties//from  w  ww. ja  v  a  2  s  .c o  m
 */
public static TypedProperties loadTypedPropertiesFromDataDescription(InitialContext ic) {
    // try to load configuration from data description
    // if data description is allocated
    TypedProperties propsFromDataDescritpion = new TypedProperties();
    // gets input stream
    try {
        Object ddconfig = (Object) ic.lookup(Keys.JPPF_CONFIG_DATADESCRIPTION);
        InputStream configInputStream = (InputStream) ddconfig;
        // loads properties
        propsFromDataDescritpion.load(configInputStream);

    } catch (NamingException e) {
        // ignore
        LogAppl.getInstance().ignore(e.getMessage(), e);
    } catch (IOException e) {
        // ignore
        LogAppl.getInstance().ignore(e.getMessage(), e);
    }
    return propsFromDataDescritpion;
}

From source file:de.micromata.genome.util.runtime.jndi.JndiDumper.java

public static String getJndiDump() {
    StringBuilder sb = new StringBuilder();
    try {//  w  ww. ja va 2  s. c  o m
        dumpJndi(sb, "");
        return sb.toString();
    } catch (NamingException ex) {
        sb.append("Error accessing naming: " + ex.getMessage());
        return sb.toString();
    }
}

From source file:chronos.TestJob.java

/**
 * @param scheduler//from w  w  w  .  ja v  a 2s  .  co  m
 *        the {@link Scheduler}
 * @throws SchedulerException
 *         on exception
 */
public static final void initializeTestJob(final Scheduler scheduler) throws SchedulerException {
    try {
        final Class<?> clazz = Class.forName(TestJob.class.getName());
        final JobDetail jobDetail = new JobDetail(TEST_JOB_NAME, CHRONOS, clazz);
        final JobDataMap jobDataMap = jobDetail.getJobDataMap();
        jobDataMap.put(InitialContext.class.getName(), new InitialContext());

        final Trigger trigger = TriggerUtils.makeMinutelyTrigger();
        trigger.setStartTime(TriggerUtils.getEvenMinuteDate(new Date()));
        trigger.setName("TestTrigger");

        scheduler.scheduleJob(jobDetail, trigger);
    } catch (final NamingException e) {
        logger.error("JNDI Exception: " + e.getMessage(), e);
    } catch (final ClassNotFoundException e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:org.apache.juddi.Registry.java

/**
 * Stops the registry.//from   w  w w . j a v a 2  s .c  o  m
 * @throws ConfigurationException 
 */
public synchronized static void stop() throws ConfigurationException {
    if (registry != null) {
        log.info("Stopping jUDDI registry...");
        if (subscriptionNotifier != null) {
            log.info("Shutting down SubscriptionNotifier");
            subscriptionNotifier.cancel();
            subscriptionNotifier = null;
        }
        if (AppConfig.getConfiguration().getBoolean(Property.JUDDI_JNDI_REGISTRATION, false)) {
            try {
                JNDIRegistration.getInstance().unregister();
            } catch (NamingException e) {
                log.error("Unable to Register jUDDI services with JNDI. " + e.getMessage(), e);
            }
        }
        registry = null;
        log.info("jUDDI shutdown completed.");
    }
}

From source file:jp.co.golorp.emarf.sql.DataSources.java

/**
 * ?//from w ww .jav  a2 s. c  om
 *
 * @return DataSource
 */
public static DataSource get() {

    if (ds != null) {
        return ds;
    }

    /*
     * JNDI??
     */

    String name = BUNDLE.getString(DATA_SOURCE_NAME);
    try {
        Context context = new InitialContext();
        ds = (DataSource) context.lookup(name);
        return ds;
    } catch (NamingException e) {
        LOG.warn(e.getMessage());
    }

    /*
     * DBCP??
     */

    Properties properties = new Properties();
    Enumeration<String> keys = BUNDLE.getKeys();
    while (keys.hasMoreElements()) {
        String key = keys.nextElement();
        String value = BUNDLE.getString(key);
        properties.put(key, value);
        // if (value.contains("mysql")) {
        // DataSources.isMySQL = true;
        // } else if (value.contains("oracle")) {
        // DataSources.isOracle = true;
        // }
    }

    try {
        ds = BasicDataSourceFactory.createDataSource(properties);
        return ds;
    } catch (Exception e) {
        throw new SystemError(e);
    }
}

From source file:org.apache.jmeter.protocol.jms.client.InitialContextFactory.java

/**
 * clear all the InitialContext objects.
 *///w  w  w .j a va2 s. c  om
public static void close() {
    for (Context ctx : MAP.values()) {
        try {
            ctx.close();
        } catch (NamingException e) {
            log.error(e.getMessage());
        }
    }
    MAP.clear();
    log.info("InitialContextFactory.close() called and Context instances cleaned up");
}

From source file:org.apache.juddi.Registry.java

/**
 * Starts the registry.//from   w ww  .  j  a  va 2 s  . c o  m
 * @throws ConfigurationException 
 */
public synchronized static void start() throws ConfigurationException {
    if (registry == null) {
        log.info("Starting jUDDI registry...");
        registry = new Registry();

        if (AppConfig.getConfiguration().getBoolean(Property.JUDDI_SUBSCRIPTION_NOTIFICATION, true)) {
            subscriptionNotifier = new SubscriptionNotifier();
        }
        if (AppConfig.getConfiguration().getBoolean(Property.JUDDI_JNDI_REGISTRATION, false)) {
            try {
                int port = AppConfig.getConfiguration().getInteger(Property.JUDDI_RMI_PORT, 0);
                JNDIRegistration.getInstance().register(port);
            } catch (NamingException e) {
                log.error("Unable to Register jUDDI services with JNDI. " + e.getMessage(), e);
            }
        }
        if (AppConfig.getConfiguration().getBoolean(Property.JUDDI_RMI_REGISTRATION, false)) {
            try {
                int rmiport = AppConfig.getConfiguration().getInteger(Property.JUDDI_RMI_REGISTRY_PORT, 1099);
                int port = AppConfig.getConfiguration().getInteger(Property.JUDDI_RMI_PORT, 0);
                RMIRegistration.getInstance(rmiport).register(port);
            } catch (Exception e) {
                log.error("Unable to Register jUDDI services with RMI Registry. " + e.getMessage(), e);
            }
        }

        log.info("jUDDI registry started successfully.");
    }
}

From source file:de.micromata.genome.util.runtime.jndi.JndiDumper.java

public static void dumpJndiBinding(InitialContext initialContext, String parentKey, Binding binding,
        StringBuilder sb, String indent) throws NamingException {
    try {//from w w w . ja  v a  2  s  . com
        Object obj = binding.getObject();
        ClassLoader bindClassLoader = obj.getClass().getClassLoader();
        sb.append(indent).append(parentKey + "/" + binding.getName()).append("(")
                .append(System.identityHashCode(binding)).append(", cl: ").append(bindClassLoader).append("): ")
                .append(binding.toString());
        if (obj instanceof Context) {

            sb.append("\n");
            Context ctx = (Context) obj;
            indent += "  ";
            NamingEnumeration<Binding> bindings = ctx.listBindings("");
            while (bindings.hasMore()) {
                Binding cbinding = bindings.next();
                dumpJndiBinding(initialContext, parentKey + "/" + binding.getName(), cbinding, sb, indent);
            }
        } else if (obj instanceof Reference) {
            Reference ref = (Reference) obj;
            //      binding.get
            //      ref.
            sb.append("\n");
        } else if (obj instanceof Session) {
            Session sess = (Session) obj;
            sb.append("\n");
        } else if (obj instanceof DataSource) {
            DataSource ds = (DataSource) obj;
            if (ds instanceof BasicDataSource) {
                BasicDataSource dbds = (BasicDataSource) ds;
                sb.append(" '" + dbds.getUrl() + "'");
            }
            sb.append("\n");
        } else if (obj != null) {
            Class<? extends Object> clazz = obj.getClass();

            sb.append(" unkown type: " + clazz);
            sb.append("\n");
        }
    } catch (NamingException ex) {
        sb.append("Error access binding: " + binding.getName() + ": " + ex.getMessage());
    }
}