Bug 39309 - tomcat can't compile big jsp, hitting a compiler limit
Summary: tomcat can't compile big jsp, hitting a compiler limit
Status: RESOLVED WORKSFORME
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 5.5.16
Hardware: All All
: P2 enhancement with 2 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
: 42958 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-04-14 09:13 UTC by David Delbecq
Modified: 2010-03-11 12:38 UTC (History)
3 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Delbecq 2006-04-14 09:13:50 UTC
Tomcat is unable to compile a JSP which has a too long section of pure html in 
it.

Because during jsp -> java operation jasper is creating 1 method per enclosing 
tag (+one jsp service method for root content), jasper is sometimes unable to 
compile a jsp. This happens because jasper splits the JSP at line break and 
converts them to out.print("......\n"); Nowhere in jsp specs is a limit 
mentioned on the number of lines. However, each out.println() is using a bit 
of code space, and you finally end up hitting the compiler limit of 64k 
maximum size of code for a method.

and you get this:
The code of method _jspService(HttpServletRequest, HttpServletResponse) is 
exceeding the 65535 bytes limit
        at 
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
        at 
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
        at 
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:413)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
        at org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)

one solution would be to rerun the .java generator when such a compilation 
error with an hint telling it to split this method's content in 2 or more 
methods.
Comment 1 Yoav Shapira 2006-06-15 18:23:43 UTC
Look at the second bullet of section 4.10 at
http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#1513.
 It's a JLS limitation.
Comment 2 Yoav Shapira 2006-06-15 18:25:33 UTC
Sorry, I submitted a little too early, didn't finish writing what I meant to say.

It's a JLS limitation on method size as I said, but I understand you run up
against that limit because of Jasper's java generation.  I myself am reluctant
to change the generator for this case, because I'm not sure it's very prevalent,
and it seems easy to work around on your end (by splitting up the JSP). 
However, if you want this feature enough to sumbit a patch for it, I'll be glad
to review that patch.
Comment 3 Mark Thomas 2006-08-30 03:54:42 UTC
This is an enhancement, marking it as such.
Comment 4 Tim Funk 2007-07-23 11:09:05 UTC
*** Bug 42958 has been marked as a duplicate of this bug. ***
Comment 5 Konstantin Kolinko 2010-03-11 12:38:02 UTC
Please note, that there is a configuration option in the JspServlet, "mappedfile".

If set to "false", adjacent println statements will be merged into a single one. See
http://tomcat.apache.org/tomcat-6.0-doc/jasper-howto.html#Configuration
and the comments in conf/web.xml


If you need anything else, implementable ideas and patches are welcome.