Bug 51532 - Performance Issue when retriving JAR files during TLD file parsing.
Summary: Performance Issue when retriving JAR files during TLD file parsing.
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 7.0.19
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2011-07-19 21:47 UTC by rstoski
Modified: 2011-07-20 21:44 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description rstoski 2011-07-19 21:47:15 UTC
Migrating from Tomcat 6.0.29 to 7.0.19 a large performance hit was noticed on pages containing lots of custom tags. Page rendering time jumped by an order of magnitude.

Profiling the webapp through Netbeans, we narrowed down the problem to the getJarFile() method inside org.apache.jasper.compiler.ParseController. Screenshots of the Profiler Hotspots and Call Tree from both versions of Tomcat are available here: http://imgur.com/a/ZmeWM

The URL path used to load the JAR file has changed from Tomcat 6. Below are the values as output by the debugger:
Tomcat 6: "file:/C:/svn/[PATH_TO_PROJECT]/server/target/snapshot/WEB-INF/lib/[OUR_JAR].jar!/"
Tomcat 7: "jndi:/localhost/snapshot/WEB-INF/lib/[OUR_JAR].jar!/"

A comparison of the getJarFile() methods shows few differences aside from the URL path that could contribute to the problem:
Tomcat 7: org.apache.jasper.compiler.JarURLResource
public JarFile getJarFile() throws IOException {
    URL jarFileUrl = new URL("jar:" + jarUrl + "!/");
    JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection();
    return conn.getJarFile();

Tomcat 6: org.apache.japser.compiler.ParserController
private JarFile getJarFile(URL jarFileUrl) throws IOException {
    JarFile jarFile = null;

    if (jarFileUrl != null) {
        JarURLConnection conn = (JarURLConnection) jarFileUrl.openConnection();
        jarFile = conn.getJarFile();

    return jarFile;
Comment 1 Konstantin Kolinko 2011-07-19 22:18:17 UTC
For reference, thread on @users before opening this issue:
Comment 2 Mark Thomas 2011-07-20 19:41:30 UTC
There is a problem with the handling of dependencies in JARs that causes JSPs with dependencies in JAR files to be recompiled on every access. I didn't check if it was as a result of the dependency changes or the JAR performance changes. Either way, it was almost certainly my fault.

I have fixed this in 7.0.x and it will be in 7.0.20 onwards. If you are willing to build Tomcat from svn (simple to do - ask on the users list if you need pointers) and confirm that this fixes the issue for you that would be very useful.
Comment 3 rstoski 2011-07-20 21:44:37 UTC
I've redeployed our webapps against a build of trunk (revision 1148915). JSPs appear to be caching properly and long access times on initial requests for JSPs has been resolved as well.