I found a bug earlier today trying to create an MBean in GlassFish. The "strange" method is com.sun.enterprise.v3.admin.DynamicInterceptor.createMBean(). When trying to create an MBean that already exists in the server I expected an InstanceAlreadyExistsException, but instead I got an MBeanException. This MBeanException had InstanceAlreadyExistsException as targetException/cause.
According to the API I should get an InstanceAlreadyExistsException. Looking at the code it seems like the last lines catches all Exceptions and throw an MBeanException. It seems like if one of the functions called inside the try-block throws an InstanceAlreadyExistsException, it should just be passed on and not thrown as the cause of an MBeanException.