The major problem is not about putting hibernate in the context's lib folder, but as you may know, hibernate does some mapping stuff, which means it reads a bunch of .hbm.xml files into memory, connects and validate these mappings everytime the context gets reloaded, and depending on how much mappings you use, a bigger problem you have, about the loading time... It takes about 30 seconds for each reload and a maximum of 4 reloads.
The difficult part of it is to make my custom ClassLoader access the webapp's classloader... because it must be placed in the server folder and because of this, it is not in the webapp's classloader hiearchy. Mine implementation speed is a little slow, i am just trying to load the classes primarly, with no errors, and then is time to think about reloading... I think it would be much easier if I could monitorate these files directly from the WebApp's classloader, but this means modify tomcat's distribution. This is all I have done so far: import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.security.AccessControlException; import java.util.Hashtable; import org.apache.catalina.loader.WebappClassLoader; public class DeployerClassLoader extends WebappClassLoader { private static Hashtable<String, Class> classes = new Hashtable<String, Class>(); private String rootFolder; public DeployerClassLoader(ClassLoader parent) { super(parent); init(); showTree(this, ""); } private String showTree(ClassLoader cls, String pre) { if (cls.getParent() != null) { pre = showTree(cls.getParent(), pre); } System.out.println(pre + " - " + cls.getClass().toString()); return pre + " "; } private void init() { System.out.println("!!!calling init!!!"); rootFolder = "/opt/tomcat/webapps/AppRoot/WEB-INF/classes/"; } private byte[] findInPath(String name) { String path = name.replaceAll("\\.", "/"); File fClass = new File(rootFolder + path + ".class"); if (fClass.exists()) { try { FileInputStream fStream = new FileInputStream(fClass); byte[] all = new byte[(int) fClass.length()]; fStream.read(all); return all; } catch (FileNotFoundException e) { return null; } catch (IOException e) { return null; } } return null; } protected Class findLoadedClass0(String name) { System.out.println("findLoaded: " + name); if (name.startsWith("br.com.agem.sige")) { // se encontrar chamar defineClass(String name, byte[] b, int off, // int len) if (classes.get(name) != null) return classes.get(name); } return super.findLoadedClass0(name); } protected Class findClassInternal(String name) throws ClassNotFoundException { byte[] data = findInPath(name); if (data != null) { synchronized (this) { Class c = defineClass(name, data, 0, data.length); classes.put(name, c); return c; } } throw new ClassNotFoundException(name); } public Class findClass(String name) throws ClassNotFoundException { if (!started) throw new ClassNotFoundException(name); // (1) Permission to define this class when using a SecurityManager if (securityManager != null) { int i = name.lastIndexOf('.'); if (i >= 0) { try { securityManager.checkPackageDefinition(name.substring(0,i)); } catch (Exception se) { throw new ClassNotFoundException(name, se); } } } // Ask our superclass to locate this class, if possible // (throws ClassNotFoundException if it is not found) Class clazz = null; try { clazz = findClassInternal(name); } catch(ClassNotFoundException cnfe) { } catch(AccessControlException ace) { throw new ClassNotFoundException(name, ace); } if (clazz == null) try { clazz = super.findClass(name); } catch(AccessControlException ace) { throw new ClassNotFoundException(name, ace); } if (clazz == null) throw new ClassNotFoundException(name); return clazz; } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]