public Object handleReflectionException(ProxyContext ctx, ReflectionException e, Method m, Object[] args) throws Exception { // use of reflection exception is inconsistent in the API so the // safest bet is to rethrow a runtime exception Exception target = e.getTargetException(); if (target instanceof RuntimeException) throw target; else throw new RuntimeProxyException(target.toString()); }
public Object handleReflectionException(ProxyContext ctx, ReflectionException e, Method m, Object[] args) throws Exception { // use of reflection exception is inconsistent in the API so the // safest bet is to rethrow a runtime exception Exception target = e.getTargetException(); if (target instanceof RuntimeException) throw target; else throw new RuntimeProxyException(target.toString()); }
public static Object getMBeanAttribute(final ObjectName objectName, final String attribute) throws OperationFailedException { try { return ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, attribute); } catch (ReflectionException e) { Throwable t = e.getTargetException(); if (t instanceof SecurityException || t instanceof UnsupportedOperationException) { throw new OperationFailedException(new ModelNode().set(t.toString())); } else if (t instanceof RuntimeException) { throw (RuntimeException) t; } else { throw new RuntimeException(t); } } catch (JMException e) { throw new RuntimeException(e); } }
public static Object getMBeanAttribute(final ObjectName objectName, final String attribute) throws OperationFailedException { try { return ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, attribute); } catch (ReflectionException e) { Throwable t = e.getTargetException(); if (t instanceof SecurityException || t instanceof UnsupportedOperationException) { throw new OperationFailedException(e.toString()); } else if (t instanceof RuntimeException) { throw (RuntimeException) t; } else { throw new RuntimeException(t); } } catch (JMException e) { throw new RuntimeException(e); } }
public static Object getMBeanAttribute(final ObjectName objectName, final String attribute) throws OperationFailedException { try { return ManagementFactory.getPlatformMBeanServer().getAttribute(objectName, attribute); } catch (ReflectionException e) { Throwable t = e.getTargetException(); if (t instanceof SecurityException || t instanceof UnsupportedOperationException) { throw new OperationFailedException(e.toString()); } else if (t instanceof RuntimeException) { throw (RuntimeException) t; } else { throw new RuntimeException(t); } } catch (JMException e) { throw new RuntimeException(e); } }
/** * Attempts to extract the "real" {@link Throwable} from some * known ones that are actually containers of others * @param e * @return */ public static final Throwable peelThrowable (Throwable e) { if (e instanceof InvocationTargetException) { return peelThrowable(((InvocationTargetException) e).getTargetException()); } else if (e instanceof MBeanException) { return peelThrowable(((MBeanException) e).getTargetException()); } else if (e instanceof ReflectionException) { return peelThrowable(((ReflectionException) e).getTargetException()); } else { return e; } } /**
targetExc = ((MBeanException) e).getTargetException(); } else if (e instanceof ReflectionException) { targetExc = ((ReflectionException) e).getTargetException(); } else if (e instanceof RuntimeMBeanException) { targetExc = ((RuntimeMBeanException) e).getTargetException();
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { // Another inconsistency if (attribute == null) throw new RuntimeOperationsException(new IllegalArgumentException("Null attribute")); try { super.setAttribute(attribute); } catch (ReflectionException e) { // Another inconsistency Exception ex = e.getTargetException(); if ((ex instanceof ClassNotFoundException) == false && (ex instanceof NoSuchMethodException) == false) { log.debug("Rewrapping reflection exception: ", e); throw new MBeanException(new ServiceNotFoundException(ex.getMessage()), e.getMessage()); } else throw e; } }
public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException { try { return super.getAttribute(name); } catch (ReflectionException e) { // Another inconsistency Exception ex = e.getTargetException(); if ((ex instanceof ClassNotFoundException) == false && (ex instanceof NoSuchMethodException) == false) { log.debug("Rewrapping reflection exception: ", e); throw new MBeanException(new ServiceNotFoundException(ex.getMessage()), e.getMessage()); } else throw e; } }
public void setAttribute(Attribute attribute) throws AttributeNotFoundException, InvalidAttributeValueException, MBeanException, ReflectionException { // Another inconsistency if (attribute == null) throw new RuntimeOperationsException(new IllegalArgumentException("Null attribute")); try { super.setAttribute(attribute); } catch (ReflectionException e) { // Another inconsistency Exception ex = e.getTargetException(); if ((ex instanceof ClassNotFoundException) == false && (ex instanceof NoSuchMethodException) == false) { log.debug("Rewrapping reflection exception: ", e); throw new MBeanException(new ServiceNotFoundException(ex.getMessage()), e.getMessage()); } else throw e; } }
public Object getAttribute(String name) throws AttributeNotFoundException, MBeanException, ReflectionException { try { return super.getAttribute(name); } catch (ReflectionException e) { // Another inconsistency Exception ex = e.getTargetException(); if ((ex instanceof ClassNotFoundException) == false && (ex instanceof NoSuchMethodException) == false) { log.debug("Rewrapping reflection exception: ", e); throw new MBeanException(new ServiceNotFoundException(ex.getMessage()), e.getMessage()); } else throw e; } }
log.error("ReflectionException", e.getTargetException()); throw e.getTargetException();
log.error("ReflectionException", e.getTargetException()); throw e.getTargetException();
Exception ex = e.getTargetException(); if ((ex instanceof ClassNotFoundException) == false && (ex instanceof NoSuchMethodException) == false)
/** * Attempt to decode the given Throwable. If it * is a container JMX exception, then the target * is returned. Otherwise the argument is returned. */ public static Throwable decode(final Throwable t) { Throwable result = t; while (true) { if (result instanceof MBeanException) result = ((MBeanException) result).getTargetException(); else if (result instanceof ReflectionException) result = ((ReflectionException) result).getTargetException(); else if (result instanceof RuntimeOperationsException) result = ((RuntimeOperationsException) result).getTargetException(); else if (result instanceof RuntimeMBeanException) result = ((RuntimeMBeanException) result).getTargetException(); else if (result instanceof RuntimeErrorException) result = ((RuntimeErrorException) result).getTargetError(); else // can't decode break; } return result; }
public void writeError(HttpOutputStream out, HttpInputStream in, Exception e) throws IOException { Exception t = e; if (e instanceof RuntimeMBeanException) { t = ((RuntimeMBeanException)e).getTargetException(); } XSLTProcessor.log(LogService.LOG_INFO,"Processing error " + t.getMessage(),null); if (t instanceof HttpException) { processHttpException(in, out, (HttpException)e); } else if ((t instanceof MBeanException) && (((MBeanException)t).getTargetException() instanceof HttpException)) { processHttpException(in, out, (HttpException)((MBeanException)t).getTargetException()); } else if ((t instanceof ReflectionException) && (((ReflectionException)t).getTargetException() instanceof HttpException)) { processHttpException(in, out, (HttpException)((ReflectionException)t).getTargetException()); } else { out.setCode(HttpConstants.STATUS_INTERNAL_ERROR); out.setHeader("Content-Type", "text/html"); out.sendHeaders(); } }
Exception ex = e.getTargetException(); if ((ex instanceof ClassNotFoundException) == false && (ex instanceof NoSuchMethodException) == false)
public void writeError(HttpOutputStream out, HttpInputStream in, Exception e) throws IOException { Logger log = getLogger(); Exception t = e; if (e instanceof RuntimeMBeanException) { t = ((RuntimeMBeanException)e).getTargetException(); } if (log.isEnabledFor(Logger.DEBUG)) log.debug("Processing error " + t.getMessage()); if (t instanceof HttpException) { processHttpException(in, out, (HttpException)t); } else if ((t instanceof MBeanException) && (((MBeanException)t).getTargetException() instanceof HttpException)) { processHttpException(in, out, (HttpException)((MBeanException)t).getTargetException()); } else if ((t instanceof ReflectionException) && (((ReflectionException)t).getTargetException() instanceof HttpException)) { processHttpException(in, out, (HttpException)((ReflectionException)t).getTargetException()); } else { out.setCode(HttpConstants.STATUS_INTERNAL_ERROR); out.setHeader("Content-Type", "text/html"); out.sendHeaders(); } }
Throwable target = ((ReflectionException) t).getTargetException(); if (target != null) { return peelException(target);
Throwable target = ((ReflectionException) t).getTargetException(); if (target != null) { return peelException(target);