/** * @param <T> the return type * @param retvalClass the returned value's {@link Class} * @param jndi the JNDI path to the resource * @return the resource at the specified {@code jndi} path */ private static <T> T lookup(Class<T> retvalClass, String jndi) { try { return retvalClass.cast(InitialContext.doLookup(jndi)); } catch (NamingException ex) { throw new IllegalArgumentException( "failed to lookup instance of " + retvalClass + " at " + jndi, ex); } }