As described in a previous post, Jasper is *extremely* slow at compiling
.tag files packaged in a .jar.  Tens of seconds every time you touch a
new .jsp for the first time.  Almost unusable if you use .tags
extensively, as I do.

The following few lines is a hack to fix this.  The added code is marked
between // -------- AJB markers.  It effectively turns off the timestamp
checking on .jar files.

This does NOT actually introduce a bug.  There is an existing bug in
that .jsp files are not automatically recompiled if any .tags in .jars
are changed.  So you need to purge work in either case.  A proper fix
would be to check dependencies properly, at least to the .jar file
itself.  But the current fix is *much* better that the existing
behavior.

COULD SOMEBODY PLEASE ARRANGE FOR THIS CODE TO BE ADDED TO THE CURRENT
SUBVERSION REPOSITORY? 

Outstanding is to make the compilation of .tags themselves much faster,
not tens of seconds.  To do that one needs to call the Java compiler
once at the end for all the .tags, rather than once for each individual
.tag which is *much* slower.

I must admit that I got rather lost reading the Jasper source, with all
the contexts etc.  Some better comments on the classes describing their
relationships to each other would be most helpful.

Thanks,

Anthony



// Tomcat 6.0.10 Src deployed version.

public class JspCompilationContext {...

    public void compile() throws JasperException, FileNotFoundException
{
        createCompiler();

        // ------------ begin AJB
        // Hack to stop .tag files that are packaged in .jars being
recompiled for every single .jsp that uses them.
        // The hack means that .tag files will not be automatically
recompiled if they change -- you need to delete work area.
        // But that was actually an existing bug -- .jsps are not
dependent on the .tag .jars so the work area needed deleting anyway.
        // (Outstanding is to compile multiple .tags in one pass and so
make the process Much faster.)
        boolean outDated;
        if (isPackagedTagFile) outDated = ! new
File(getClassFileName()).exists();
        else outDated = jspCompiler.isOutDated();
//        AjbLog.log("### Compiler.compile " + jspUri + " pkgTagFile " +
isPackagedTagFile + " outDated " + outDated + " " + getClassFileName());
        if (outDated) {
//     if (isPackagedTagFile || jspCompiler.isOutDated()) {
//     ---------------- end AJB
            try {
                jspCompiler.removeGeneratedFiles();
                jspLoader = null;
                jspCompiler.compile();
                jsw.setReload(true);
                jsw.setCompilationException(null);
            } catch (JasperException ex) {
                // Cache compilation exception
                jsw.setCompilationException(ex);
                throw ex;
            } catch (Exception ex) {
                JasperException je = new JasperException(
 
Localizer.getMessage("jsp.error.unable.compile"),
                            ex);
                // Cache compilation exception
                jsw.setCompilationException(je);
                throw je;
            }
        }
    }

--
Dr Anthony Berglas 
Ph. +61 7 3227 4410
Mob. +61 44 838 8874
[EMAIL PROTECTED]; [EMAIL PROTECTED]


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to