larryi 01/01/22 13:37:31 Modified: src/share/org/apache/tomcat/modules/config AutoSetup.java Log: Fix classloader problem which occurs when a war file gets expanded for a context that is already listed in the server.xml. The classloader gets created by server.xml processing before the war file is expanded. When SimpleClassLoader is used, it will lack the WEB-INF directories in its urls[] array. Make AutoSetup remove and add the context so the classloader gets updated. Fixed the indentation to make it more readable, though it somewhat hides the actual changes. Revision Changes Path 1.3 +30 -20 jakarta-tomcat/src/share/org/apache/tomcat/modules/config/AutoSetup.java Index: AutoSetup.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/modules/config/AutoSetup.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- AutoSetup.java 2001/01/01 03:42:58 1.2 +++ AutoSetup.java 2001/01/22 21:37:29 1.3 @@ -110,6 +110,7 @@ } for (int i = 0; i < list.length; i++) { String name = list[i]; + boolean expanded = false; if( name.endsWith(".war") ) { String fname=name.substring(0, name.length()-4); File appDir=new File( home + "/webapps/" + fname); @@ -121,6 +122,7 @@ try { FileUtil.expand(home + "/webapps/" + name, home + "/webapps/" + fname); + expanded=true; } catch( IOException ex) { log("expanding webapp " + name, ex); // do what ? @@ -145,26 +147,34 @@ if( path.equals("/ROOT") ) path=""; - if( definedContexts.get(path) == null ) { - // if no explicit set up and is a directory - File f=new File( webappD, name); - if (f.isDirectory()) { - Context ctx=new Context(); - ctx.setContextManager( cm ); - ctx.setPath(path); - definedContexts.put( path, ctx ); - // use absolute filename based on CM home instead of relative - // don't assume HOME==TOMCAT_HOME - ctx.setDocBase( f.getAbsolutePath() ); - if( debug > 0 ) - log("automatic add " + ctx.toString() + " " + path); - cm.addContext(ctx); - ctx.init(); - } else { - if( debug>0) - log("Already set up: " + path + " " - + definedContexts.get(path)); - } + Context ctx = (Context)definedContexts.get(path); + // if context not defined or was expanded + if( ctx == null || expanded ) { + // if no explicit set up and is a directory + File f=new File( webappD, name); + if (f.isDirectory()) { + // If the context is already defined and was expanded, + // we need to remove it since it was initialized before + // its directories existed. At minimum, its classloader + // needs updating. + if ( ctx != null ) + cm.removeContext(ctx); + ctx=new Context(); + ctx.setContextManager( cm ); + ctx.setPath(path); + definedContexts.put( path, ctx ); + // use absolute filename based on CM home instead of relative + // don't assume HOME==TOMCAT_HOME + ctx.setDocBase( f.getAbsolutePath() ); + if( debug > 0 ) + log("automatic add " + ctx.toString() + " " + path); + cm.addContext(ctx); + ctx.init(); + } else { + if( debug>0) + log("Already set up: " + path + " " + + definedContexts.get(path)); + } } } } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]