private static void setClassLoader ( File hdConfDir , Configuration conf ) throws Exception { ClassLoader parent = conf . getClassLoader ( ) ; URL url = hdConfDir . toURI ( ) . toURL ( ) ; URL [ ] urls = new URL [ 1 ] ; urls [ 0 ] = url ; ClassLoader classLoader = new URLClassLoader ( urls , parent ) ; Thread . currentThread ( ) . setContextClassLoader ( classLoader ) ; conf . setClassLoader ( classLoader ) ; }
Set class loader for current thread and for Confifguration based on Hadoop home .