DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11158>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11158 WebappClassLoader does'nt find any class in an external repository Summary: WebappClassLoader does'nt find any class in an external repository Product: Tomcat 4 Version: 4.0.4 Final Platform: PC OS/Version: Windows NT/2K Status: NEW Severity: Major Priority: Other Component: Catalina AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] The method "findClassInternal" cannot return "null" when the required class is not in one of the "local repositories" but in one of the "external repositories". In this case, this method throws an exception and it does'not return "null" This implies that the call to "super.findClass(name);" in the method "findClass" of "WebappClassLoader "(line 954) cannot be done. To reproduce this bug you must add an extenal repository to the set of places the "WebappClassLoader" can look for classes to be loaded. To do that, I propose you to call my method "addRepositoryInClassLoader" in the "init" method of the first servlet "load-on-startups" //-------------------------------------------------------------------- private static String CATALINA_LOADER ="org.apache.catalina.loader.WebappClassLoader"; //-------------------------------------------------------------------- /** * invoke the method "public void addRepository(String repository)" * if it is an instance of "org.apache.catalina.loader.WebappClassLoader" */ private void addRepositoryInClassLoader(String aRepository) throws ServletException { ClassLoader wClassLoader = Thread.currentThread().getContextClassLoader(); String wClassLoaderName = wClassLoader.getClass().getName(); log("---setClassLoader:"); log(CStringFacilities.toStringDescr("ClassLoaderName",wClassLoaderName)); /* this test replace "instanceof" which return false if the tested class is instancied by an other class loader (other name space !)*/ if (wClassLoaderName.equals(CATALINA_LOADER)){ /* build the URL of the external repository */ String wUrl = "file:"+ aRepository; /* invoke addRepository(String aRep) */ try { Class[] wParameterTypes = new Class[]{String.class}; Object[] wArguments = new Object[] {wUrl}; Method wMethodAddRepository = wClassLoader.getClass().getMethod ("addRepository",wParameterTypes ); wMethodAddRepository.invoke(wClassLoader,wArguments); } catch (Exception e) { log("Can't invoke addRepository(String aRep)\n" + CStringFacilities.eToString(e)); } /* invoke getURLs() */ try { Method wMethodGetUrl = wClassLoader.getClass().getMethod("getURLs",new Class[0] ); RL[] wUrls = (URL[])wMethodGetUrl.invoke(wClassLoader, new Object[0] ); int wMax = wUrls.length; for (int wI=0;wI<wMax;wI++){ log(CStringFacilities.toStringDescr("external repository ["+wI+"]",wUrls[wI].toString() )); } } catch (Exception e) { log("Can't invoke getURLs()\n" +CStringFacilities.eToString(e)); } } } -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
