/** * Utility method for looking up an Object via JNDI. Prefixes <code>java:comp/env/</code> * to <code>location</code>. If that is not found, it retries without the prefix. * * @param location JNDI location */ public final static Object lookup(String location) throws NamingException, RemoteException { // if already determined that env location should be ignored... NamingException notFoundE = null; if (ignoreEnvLocations.contains(location)) { try { return getRoot().lookup(location); } catch (NamingException e) { // hmmm... maybe it's changed location in the JNDI tree ignoreEnvLocations.remove(location); notFoundE = e; } } try { return getRoot().lookup("java:comp/env/" + location); } catch (NamingException e) { if (notFoundE != null) { throw notFoundE; // throw first exception if it exists } ignoreEnvLocations.add(location); return getRoot().lookup(location); } }
/** * Utility method for looking up an Object via JNDI. Prefixes <code>java:comp/env/</code> * to <code>location</code>. If that is not found, it retries without the prefix. * * @param location JNDI location */ public final static Object lookup(String location) throws NamingException, RemoteException { // if already determined that env location should be ignored... NamingException notFoundE = null; if (ignoreEnvLocations.contains(location)) { try { return getRoot().lookup(location); } catch (NamingException e) { // hmmm... maybe it's changed location in the JNDI tree ignoreEnvLocations.remove(location); notFoundE = e; } } try { return getRoot().lookup("java:comp/env/" + location); } catch (NamingException e) { if (notFoundE != null) { throw notFoundE; // throw first exception if it exists } ignoreEnvLocations.add(location); return getRoot().lookup(location); } }