/** * @return the ClassLoader that will be associated with the DU. It will load * the classes in the DU and will be also used for JNDI objects * under ENC - java:comp/env * @throws DeploymentException */ protected RepositoryClassLoader createDUClassLoader() throws DeploymentException { try { UnifiedClassLoader ucl = (UnifiedClassLoader) Thread .currentThread().getContextClassLoader(); UnifiedLoaderRepository3 lr = (UnifiedLoaderRepository3) ucl .getLoaderRepository(); RepositoryClassLoader cl = lr.newClassLoader( getTempClassDeploymentDir().toURL(), new File( getUnitJarFile().getName()).toURL(), true); // make sure to call ucl.unregister() on undeploy() return cl; } catch (MalformedURLException e1) { throw new DeploymentException( "Bad ULR for tempClassDeploymentDir: " + getTempClassDeploymentDir()); } catch (Exception e) { throw new DeploymentException( "Failed Creating ClassLoader for tempClassDeploymentDir: " + getTempClassDeploymentDir()); } }