Description
See org.apache.deltaspike.core.impl.jmx.DynamicMBeanWrapper.invoke(String, Object[], String[]):
if (operations.containsKey(actionName)) { final ClassLoader oldCl = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(classloader); try { return operations.get(actionName).invoke(instance(), params); } catch (IllegalArgumentException e) { LOGGER.log(Level.SEVERE, actionName + "can't be invoked", e); } catch (IllegalAccessException e) { LOGGER.log(Level.SEVERE, actionName + "can't be invoked", e); } catch (InvocationTargetException e) { LOGGER.log(Level.SEVERE, actionName + "can't be invoked", e); } finally { Thread.currentThread().setContextClassLoader(oldCl); } } throw new MBeanException(new IllegalArgumentException(), actionName + " doesn't exist");
When the MBean method throws an exception, the wrapper catches and logs the InvocationTargetException. But as the last step a MBeanException with cause actionName + " doesn't exist" is thrown, regardless of what went wrong actually!
The "doesn't exist" exception should be moved into an else block.
The specificly caught exception should be wrapped into a new MBeanException which should be thrown afterwards. If wrapping is not possible due to classloadings constraints, at least the message of the original exception should be retained.