public static boolean waitForRemovalFromJNDI(final Context ctx, final String jndiName, long timeout) {
        boolean removed = false;
        while (!removed && timeout > 0) {
            try {
                ctx.lookup(jndiName);
            } catch (NameNotFoundException ex) {
                removed = true;
            } catch (NamingException ex) {
                throw new RuntimeException("Failed JNDI lookup for " + jndiName, ex);
            }

            try {
                Thread.sleep(10);
            } catch (InterruptedException ex) {
                throw new RuntimeException("Interrupted while doing JNDI lookup for " + jndiName);
            }

            timeout -= 10;
        }

        return removed;
    }
public static boolean waitForRemovalFromJNDI ( final Context ctx , final String jndiName , long timeout ) { boolean removed = false ; while ( ! removed && timeout > 0 ) { try { ctx . lookup ( jndiName ) ; } catch ( NameNotFoundException ex ) { removed = true ; } catch ( NamingException ex ) { throw new RuntimeException ( "Failed JNDI lookup for " + jndiName , ex ) ; } try { Thread . sleep ( 10 ) ; } catch ( InterruptedException ex ) { throw new RuntimeException ( "Interrupted while doing JNDI lookup for " + jndiName ) ; } timeout -= 10 ; } return removed ; }
this can't be recursive, as it can blow the stack