/** * Return a general naming exception with a root cause. * * @param message the message * @param cause the exception cause, or {@code null} for none * @return the exception */ public static NamingException namingException(final String message, final Throwable cause) { final NamingException exception = new NamingException(message); if (cause != null) exception.initCause(cause); return exception; }
Context ctx = NamingManager.getURLContext(scheme, environment); if (ctx == null) { throw new NamingException("scheme " + scheme + " not recognized"); Object obj = bindings.get(first); if (obj == null) { throw new NameNotFoundException(name); } else if (obj instanceof Context && path.size() > 1) { Context subContext = (Context) obj; throw e; } catch (Exception e) { throw (NamingException) new NamingException("could not look up : " + name).initCause(e);
ne = new NameNotFoundException(); ne = new ContextNotEmptyException(); } else { ne = new NamingException();
protected RedissonClient buildClient(String configPath) throws NamingException { Config config = null; try { config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); } catch (IOException e) { // trying next format try { config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); } catch (IOException e1) { NamingException ex = new NamingException("Can't parse yaml config " + configPath); ex.initCause(e1); throw ex; } } try { return Redisson.create(config); } catch (Exception e) { NamingException ex = new NamingException(); ex.initCause(e); throw ex; } }
public void unbind(String name) throws NamingException { checkName(name); Registry registry = getRegistry(); try { registry.unbind(toRMIName(name)); } catch (NotBoundException ex) { throw new NameNotFoundException(name + " not found in RMI registry " + registry); } catch (RemoteException ex) { throw new NamingException("Remote exception: " + ex.getMessage()); } }
Context ctx = NamingManager.getURLContext(scheme, environment); if (ctx == null) { throw new NamingException("scheme " + scheme + " not recognized"); Object obj = bindings.get(first); if (obj == null) { throw new NameNotFoundException(name); } else if (obj instanceof Context && path.size() > 1) { Context subContext = (Context)obj; throw e; } catch (Exception e) { throw (NamingException)new NamingException("could not look up : " + name).initCause(e);
protected RedissonClient buildClient(String configPath) throws NamingException { Config config = null; try { config = Config.fromJSON(new File(configPath), getClass().getClassLoader()); } catch (IOException e) { // trying next format try { config = Config.fromYAML(new File(configPath), getClass().getClassLoader()); } catch (IOException e1) { NamingException ex = new NamingException("Can't parse yaml config " + configPath); ex.initCause(e1); throw ex; } } try { return Redisson.create(config); } catch (Exception e) { NamingException ex = new NamingException(); ex.initCause(e); throw ex; } }
public void unbind(String name) throws NamingException { checkName(name); Registry registry = getRegistry(); try { registry.unbind(toRMIName(name)); } catch (NotBoundException ex) { throw new NameNotFoundException(name + " not found in RMI registry " + registry); } catch (RemoteException ex) { throw new NamingException("Remote exception: " + ex.getMessage()); } }
Context ctx = NamingManager.getURLContext(scheme, environment); if (ctx == null) { throw new NamingException("scheme " + scheme + " not recognized"); Object obj = bindings.get(first); if (obj == null) { throw new NameNotFoundException(name); } else if (obj instanceof Context && path.size() > 1) { Context subContext = (Context) obj; throw e; } catch (Exception e) { throw (NamingException) new NamingException("could not look up : " + name).initCause(e);
@Override public final NamingException cannotDeferenceObject(final Throwable cause) { final NamingException result = new NamingException(String.format(getLoggingLocale(), cannotDeferenceObject$str())); result.initCause(cause); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String cannotListNonContextBinding = "WFLYNAM0017: Unable to list a non Context binding.";
public void unbind(String name) throws NamingException { if (TraceCarol.isDebugJndiCarol()) TraceCarol.debugJndiCarol("unbind(" + name + ")"); if (name.equals("")) { throw new InvalidNameException("Cannot unbind empty name"); } try { reg.unbind(name); } catch (java.rmi.RemoteException e) { throw new NamingException(e.toString()); } catch (java.rmi.NotBoundException e) { throw new NameNotFoundException(e.toString()); } }
@Override public final NamingException failedToInstantiate(final Throwable cause, final String description, final String className, final ClassLoader classLoader) { final NamingException result = new NamingException(String.format(getLoggingLocale(), failedToInstantiate$str(), description, className, classLoader)); result.initCause(cause); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String failedToReadContextEntries = "WFLYNAM0028: Failed to read %s context entries.";
public Object lookup(String name) throws NamingException { checkName(name); name = toRMIName(name); if (name.length() == 0) { return new RMIContext(environment); } Registry registry = getRegistry(); try { return registry.lookup(name); } catch (NotBoundException ex) { throw new NameNotFoundException(name + " not found in RMI registry " + registry); } catch (RemoteException ex) { throw new NamingException("Remote exception: " + ex.getMessage()); } }
@Override public final NamingException objectFactoryCreationFailure(final Throwable cause) { final NamingException result = new NamingException(String.format(getLoggingLocale(), objectFactoryCreationFailure$str())); result.initCause(cause); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String readOnlyNamingContext = "WFLYNAM0043: Naming context is read-only";
public Object lookup(String name) throws NamingException { checkName(name); name = toRMIName(name); if (name.length() == 0) { return new RMIContext(environment); } Registry registry = getRegistry(); try { return registry.lookup(name); } catch (NotBoundException ex) { throw new NameNotFoundException(name + " not found in RMI registry " + registry); } catch (RemoteException ex) { throw new NamingException("Remote exception: " + ex.getMessage()); } }
@Override public final NamingException lookupError(final Throwable cause, final String name) { final NamingException result = new NamingException(String.format(getLoggingLocale(), lookupError$str(), name)); result.initCause(cause); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String serviceNotStarted = "WFLYNAM0063: %s service not started";
public void unbind(Name name) throws NamingException { String attrName = getRelativeName(name); FileObject fo = dobj.getPrimaryFile(); if (fo.getAttribute(attrName) == null) { NamingException ne = new NameNotFoundException(); ne.setResolvedName(name); throw ne; } try { fo.setAttribute(attrName, null); } catch (IOException ex) { NamingException ne = new NamingException(); // NOI18N ne.setResolvedName(name); ne.setRootCause(ex); } }
@Override public final NamingException obtainingDirContextCredentialFromAuthenticationContextFailed(final Throwable cause) { final NamingException result = new NamingException(String.format(getLoggingLocale(), obtainingDirContextCredentialFromAuthenticationContextFailed$str())); result.initCause(cause); final StackTraceElement[] st = result.getStackTrace(); result.setStackTrace(Arrays.copyOfRange(st, 1, st.length)); return result; } private static final String authenticationFailedEvidenceVerification = "ELY01151: Evidence Verification Failed.";
@Override protected Context getURLOrDefaultInitCtx(String name) throws NamingException { String scheme = getURLScheme(name); if (scheme != null && !scheme.equals("java")) { ObjectFactory factory = urlContextFactories.get(scheme); if (factory != null) { try { return (Context) factory.getObjectInstance(null, null, null, myProps); }catch(NamingException e) { throw e; } catch (Exception e) { NamingException n = new NamingException(e.getMessage()); n.initCause(e); throw n; } } else { Context ctx = delegate.getInitialContext(myProps); if(ctx!=null) { return ctx; } } } return getDefaultInitCtx(); }
private Object processInvocation(Name name, HttpString method, String pathSegment, Name newName) throws NamingException { ProviderEnvironment environment = httpNamingProvider.getProviderEnvironment(); final RetryContext context = canRetry(environment) ? new RetryContext() : null; return performWithRetry((contextOrNull, name1, param) -> { try { HttpNamingProvider.HttpPeerIdentity peerIdentity = (HttpNamingProvider.HttpPeerIdentity) httpNamingProvider.getPeerIdentityForNamingUsingRetry(contextOrNull); StringBuilder sb = new StringBuilder(); String uriPath = peerIdentity.getUri().getPath(); sb.append(uriPath); if (!uriPath.endsWith("/")) { sb.append("/"); } sb.append(pathSegment) .append(URLEncoder.encode(name.toString(), StandardCharsets.UTF_8.name())); if (newName != null) { sb.append("?new="); sb.append(URLEncoder.encode(newName.toString(), StandardCharsets.UTF_8.name())); } final ClientRequest clientRequest = new ClientRequest() .setPath(sb.toString()) .setMethod(method); clientRequest.getRequestHeaders().put(Headers.ACCEPT, ACCEPT_VALUE); return performOperation(name1, peerIdentity.getUri(), clientRequest); } catch (UnsupportedEncodingException e) { NamingException namingException = new NamingException(e.getMessage()); namingException.initCause(e); throw namingException; } }, environment, context, name, null); }