kinman 2003/02/21 10:23:14 Modified: jasper2/src/bin jasper.sh jspc.sh jasper2/src/share/org/apache/jasper JspC.java JspCompilationContext.java jasper2/src/share/org/apache/jasper/compiler JspRuntimeContext.java TagFileProcessor.java TagLibraryInfoImpl.java Log: - Applied Hans Bergsten's patch on TagLibraryInfoImpl for Jspc problem. - Reverted mods to TagFileProcessor.java - Created a dummy JspRuntimeContext for handling tag file compilations. - Added debugging option to jspc.sh Manual precompilation with jspc.sh seems to work now, but precompilation in ant still fail. The problem seems to be related to processing tld in jars. Weird. Stay tuned. Revision Changes Path 1.5 +11 -1 jakarta-tomcat-jasper/jasper2/src/bin/jasper.sh Index: jasper.sh =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/bin/jasper.sh,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- jasper.sh 4 Aug 2002 18:21:08 -0000 1.4 +++ jasper.sh 21 Feb 2003 18:23:14 -0000 1.5 @@ -87,6 +87,16 @@ exec "$_RUNJAVA" $JAVA_OPTS $JASPER_OPTS \ -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ -Djasper.home="$JASPER_HOME" \ + -Dcatalina.home="$JASPER_HOME" \ + org.apache.jasper.JspC "$@" + +elif [ "$1" = "debug" ] ; then + + shift + exec "$_RUNJDB" $JAVA_OPTS $JASPER_OPTS \ + -Djava.endorsed.dirs="$JAVA_ENDORSED_DIRS" -classpath "$CLASSPATH" \ + -Djasper.home="$JASPER_HOME" \ + -Dcatalina.home="$JASPER_HOME" \ org.apache.jasper.JspC "$@" else 1.4 +7 -2 jakarta-tomcat-jasper/jasper2/src/bin/jspc.sh Index: jspc.sh =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/bin/jspc.sh,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- jspc.sh 4 Aug 2002 18:21:08 -0000 1.3 +++ jspc.sh 21 Feb 2003 18:23:14 -0000 1.4 @@ -28,4 +28,9 @@ exit 1 fi -exec "$PRGDIR"/"$EXECUTABLE" jspc "$@" +if [ "$1" = "debug" ]; then + shift + exec "$PRGDIR"/"$EXECUTABLE" debug "$@" +else + exec "$PRGDIR"/"$EXECUTABLE" jspc "$@" +fi 1.30 +23 -12 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java Index: JspC.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- JspC.java 10 Feb 2003 10:31:49 -0000 1.29 +++ JspC.java 21 Feb 2003 18:23:14 -0000 1.30 @@ -68,13 +68,12 @@ import org.apache.jasper.compiler.ServletWriter; import org.apache.jasper.compiler.Compiler; import org.apache.jasper.compiler.TldLocationsCache; - -import org.apache.jasper.servlet.JspCServletContext; - -import org.apache.jasper.compiler.JspConfig; import org.apache.jasper.compiler.JspConfig; import org.apache.jasper.compiler.TagPluginManager; import org.apache.jasper.compiler.Localizer; +import org.apache.jasper.compiler.JspRuntimeContext; +import org.apache.jasper.servlet.JspCServletContext; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -195,6 +194,10 @@ static PrintStream logStream; JspCServletContext context; + /* + * Maintain a dummy JspRuntimeContext for compiling tag files + */ + JspRuntimeContext rctxt; /** * Cache for the TLD locations @@ -204,6 +207,7 @@ private JspConfig jspConfig = null; private TagPluginManager tagPluginManager = null; + private boolean verbose = false; private boolean listErrors = false; private boolean showSuccess = false; @@ -530,7 +534,7 @@ String baseDir = scratchDir.getCanonicalPath(); this.setOutputDir( baseDir + jspUri.substring( 0, jspUri.lastIndexOf( '/' ) ) ); JspCompilationContext clctxt = new JspCompilationContext - ( jspUri, false, this, context, null, null ); + ( jspUri, false, this, context, null, rctxt ); /* Override the defaults */ if ((targetClassName != null) && (targetClassName.length() > 0)) { @@ -591,6 +595,8 @@ e); if ( listErrors ) { logStream.println( "Error in File: " + file ); + logStream.println(e.getMessage()); + e.printStackTrace(logStream); return true; } else if (dieLevel != NO_DIE_LEVEL) { dieOnExit = true; @@ -745,12 +751,13 @@ (new PrintWriter(System.out), new URL("file:" + uriRoot.replace('\\','/') + '/')); tldLocationsCache = new - TldLocationsCache(context); + TldLocationsCache(context, true); } catch (MalformedURLException me) { System.out.println("**" + me); } - jspConfig = new JspConfig(context); - tagPluginManager = new TagPluginManager(context); + rctxt = new JspRuntimeContext(context, this); + jspConfig = new JspConfig(context); + tagPluginManager = new TagPluginManager(context); } @@ -865,7 +872,11 @@ die = dieLevel; while ((tok = nextArg()) != null) { - if (tok.equals(SWITCH_OUTPUT_DIR)) { + if (tok.equals(SWITCH_VERBOSE)) { + verbose = true; + showSuccess = true; + listErrors = true; + } else if (tok.equals(SWITCH_OUTPUT_DIR)) { tok = nextArg(); setOutputDir( tok ); } else if (tok.equals(SWITCH_OUTPUT_SIMPLE_DIR)) { 1.34 +3 -5 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java Index: JspCompilationContext.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspCompilationContext.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- JspCompilationContext.java 19 Feb 2003 07:39:49 -0000 1.33 +++ JspCompilationContext.java 21 Feb 2003 18:23:14 -0000 1.34 @@ -201,8 +201,6 @@ public ClassLoader getClassLoader() { if( loader != null ) return loader; - if( rctxt == null) - return getClass().getClassLoader(); return rctxt.getParentClassLoader(); } 1.11 +10 -5 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspRuntimeContext.java Index: JspRuntimeContext.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/JspRuntimeContext.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- JspRuntimeContext.java 22 Jan 2003 20:08:24 -0000 1.10 +++ JspRuntimeContext.java 21 Feb 2003 18:23:14 -0000 1.11 @@ -185,8 +185,13 @@ } } - initSecurity(); initClassPath(); + + if (context instanceof org.apache.jasper.servlet.JspCServletContext) { + return; + } + + initSecurity(); // If this web application context is running from a // directory, start the background compilation thread 1.44 +45 -64 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java Index: TagFileProcessor.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagFileProcessor.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- TagFileProcessor.java 21 Feb 2003 16:29:51 -0000 1.43 +++ TagFileProcessor.java 21 Feb 2003 18:23:14 -0000 1.44 @@ -412,78 +412,59 @@ JspCompilationContext ctxt = compiler.getCompilationContext(); JspRuntimeContext rctxt = ctxt.getRuntimeContext(); - JspServletWrapper wrapper = null; - int tripCount; - if( rctxt != null ) { - wrapper = + JspServletWrapper wrapper = (JspServletWrapper) rctxt.getWrapper(tagFilePath); - synchronized(rctxt) { - if (wrapper == null) { - wrapper = new JspServletWrapper(ctxt.getServletContext(), - ctxt.getOptions(), - tagFilePath, - tagInfo, - ctxt.getRuntimeContext(), - (JarFile) ctxt.getTagFileJars().get(tagFilePath)); + synchronized(rctxt) { + if (wrapper == null) { + wrapper = new JspServletWrapper(ctxt.getServletContext(), + ctxt.getOptions(), + tagFilePath, + tagInfo, + ctxt.getRuntimeContext(), + (JarFile) ctxt.getTagFileJars().get(tagFilePath)); rctxt.addWrapper(tagFilePath,wrapper); - } - tripCount = wrapper.incTripCount(); - } - } else { - wrapper = new JspServletWrapper(ctxt.getServletContext(), - ctxt.getOptions(), - tagFilePath, - tagInfo, - ctxt.getRuntimeContext(), - (JarFile)ctxt.getTagFileJars().get(tagFilePath) - ); - tripCount = wrapper.incTripCount(); - } - - Class tagClazz; - try { - if (tripCount > 0) { - // When tripCount is greater than zero, a circular - // dependency exists. The circularily dependant tag - // file is compiled in prototype mode, to avoid infinite - // recursion. + Class tagClazz; + int tripCount = wrapper.incTripCount(); + try { + if (tripCount > 0) { + // When tripCount is greater than zero, a circular + // dependency exists. The circularily dependant tag + // file is compiled in prototype mode, to avoid infinite + // recursion. - JspServletWrapper tempWrapper - = new JspServletWrapper(ctxt.getServletContext(), - ctxt.getOptions(), - tagFilePath, - tagInfo, - ctxt.getRuntimeContext(), - (JarFile) ctxt.getTagFileJars().get(tagFilePath)); - tempWrapper.getJspEngineContext() - .setClassPath(ctxt.getClassPath()); - tagClazz = tempWrapper.loadTagFilePrototype(); - tempVector.add( + JspServletWrapper tempWrapper + = new JspServletWrapper(ctxt.getServletContext(), + ctxt.getOptions(), + tagFilePath, + tagInfo, + ctxt.getRuntimeContext(), + (JarFile) ctxt.getTagFileJars().get(tagFilePath)); + tagClazz = tempWrapper.loadTagFilePrototype(); + tempVector.add( tempWrapper.getJspEngineContext().getCompiler()); - } else { - wrapper.getJspEngineContext() - .setClassPath(ctxt.getClassPath()); - tagClazz = wrapper.loadTagFile(); + } else { + tagClazz = wrapper.loadTagFile(); + } + } finally { + wrapper.decTripCount(); } - } finally { - wrapper.decTripCount(); - } - // Add the dependants for this tag file to its parent's - // dependant list. - PageInfo pageInfo = wrapper.getJspEngineContext().getCompiler(). - getPageInfo(); - if (pageInfo != null) { - Iterator iter = pageInfo.getDependants().iterator(); - if (iter.hasNext()) { - parentPageInfo.addDependant((String)iter.next()); + // Add the dependants for this tag file to its parent's + // dependant list. + PageInfo pageInfo = wrapper.getJspEngineContext().getCompiler(). + getPageInfo(); + if (pageInfo != null) { + Iterator iter = pageInfo.getDependants().iterator(); + if (iter.hasNext()) { + parentPageInfo.addDependant((String)iter.next()); + } } - } - return tagClazz; + return tagClazz; + } } 1.35 +5 -7 jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java Index: TagLibraryInfoImpl.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/compiler/TagLibraryInfoImpl.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- TagLibraryInfoImpl.java 22 Jan 2003 21:06:44 -0000 1.34 +++ TagLibraryInfoImpl.java 21 Feb 2003 18:23:14 -0000 1.35 @@ -207,10 +207,6 @@ InputStream stream = null; try { String path = location[0] ; - if(ctxt.getClassLoader() != null && - URLClassLoader.class.equals(ctxt.getClassLoader().getClass()) - && path.startsWith("/")) - path = path.substring(1,path.length()) ; url = ctxt.getResource(path); if (url == null) return; url = new URL("jar:" + url.toString() + "!/"); @@ -232,11 +228,13 @@ stream.close(); } catch (Throwable t) {} } + /* if (jarFile != null) { try { jarFile.close(); } catch (Throwable t) {} } + */ throw new JasperException(ex); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]