private static Context createExternalContext(String spaceName) { try { //using the jndi.properties which is located in the classpath //,and use its Context details in order to connect to other InitialContext return new InitialContext(); } catch (Exception ex) { if (_logger.isLoggable(Level.SEVERE)) { if (ex instanceof NamingException) { String cause = ((NamingException) ex).getRootCause().toString(); _logger.log(Level.SEVERE, "Failed to create InitialContext and register JMS Admin Objects on space " + "<" + spaceName + "> using the external JNDI lookup service | " + cause, ex); } else _logger.log(Level.SEVERE, "Failed to create InitialContext and register JMS Admin Objects on space " + "<" + spaceName + "> using the external JNDI lookup service | " + ex.toString(), ex); } return null; } } }
public String getCode() { if(getCause() instanceof NamingException) { NamingException nex = (NamingException) getCause(); return nex.getRootCause() != null ? nex.getRootCause().getMessage() : nex.getExplanation(); } else { return null; } } }
protected void rebind(String name, Object obj, String desc) { //binds to an internal jndi context if (internalContext != null) { try { internalContext.rebind(name, obj); if (_logger.isLoggable(Level.INFO)) _logger.info("JMS " + desc + " < " + name + " > bound successfully to the RMIRegistry lookup service."); } catch (NamingException e) { if (_logger.isLoggable(Level.WARNING)) { _logger.log(Level.WARNING, "Failed to register < " + name + " > JMS Admin Object, on space " + "<" + spaceName + "> using the the RMIRegistry lookup service: " + internalContext + " | ", e); } } } //binds to an External jndi context returns true if success , other wise error message. if (externalContext != null) { try { externalContext.rebind(name, obj); if (_logger.isLoggable(Level.INFO)) _logger.info("JMS " + desc + " < " + name + " > bound successfully to the External JNDI lookup service: " + externalContext.getEnvironment().toString()); } catch (NamingException e) { if (_logger.isLoggable(Level.SEVERE)) { _logger.log(Level.SEVERE, "Failed to register < " + name + " > JMS Admin Object, on space " + "<" + spaceName + "> using the external JNDI lookup service: " + externalContext + " | " + e.getRootCause().getMessage(), e); } } } }
_logger.log(Level.WARNING, "Failed to unbind the < " + name + " > JMS Admin Object, from space " + "<" + spaceName + "> using the the RMIRegistry lookup service: " + internalContext + " | " + e.getRootCause().toString(), e); _logger.log(Level.WARNING, "Failed to unbind the < " + name + " > JMS Admin Object, from space " + "<" + spaceName + "> using the external JNDI lookup service: " + externalContext + " | " + e.getRootCause().toString(), e);
/** * Create the naming manager. * @throws NamingException if no initial context is built */ private SingletonNamingManager() throws NamingException { try { ictx = new InitialContext(); // there is a bug in carol that makes this not work. //myEnv = ictx.getEnvironment(); clBindings = new Hashtable(); } catch (NamingException n) { logger.log(BasicLevel.ERROR, "NamingManager: " + n.getExplanation()); Throwable t = n.getRootCause(); if (t != null) { if (t.getMessage().startsWith("Connection refused to host:")) { logger.log(BasicLevel.ERROR, "NamingManager: rmi registry not started ?"); } else { logger.log(BasicLevel.ERROR, "NamingManager: " + t.getMessage()); } } throw n; } }
if (_logger.isLoggable(Level.WARNING)) { if (ex instanceof NamingException) { Throwable rootException = ((NamingException) ex).getRootCause(); if (rootException != null) cause = rootException.toString();
Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException)
Throwable t = e.getRootCause(); if (t instanceof ClassNotFoundException)
if (e.getRootCause() instanceof ConnectException){ throw new ClientVisibleException(ResponseCodes.BAD_REQUEST, INVALID_OPEN_LDAP_CONFIG, "Unable to talk to ldap.", "Provided server and port refused connection.");