// create two identical mbeans
server.registerMBean(rmm, oname);
server.registerMBean(rmm, oname2);
ProxyContext ctx = (ProxyContext)MBeanProxy.get(
MyInterface.class, oname, server
);
// override InstanceNotFound exception to redirect from test=test instance
// to test=test2 instance
ctx.setExceptionHandler(new DefaultExceptionHandler()
{
public Object handleInstanceNotFound(ProxyContext proxyCtx, InstanceNotFoundException e, Method m, Object[] args) throws Exception
{
return proxyCtx.getMBeanServer().invoke(new ObjectName("test:test=test2"), m.getName(), args, null);
}