You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nick Williams <ni...@nicholaswilliams.net> on 2011/04/07 17:20:33 UTC

Issue compiling a JSP in old and new versions of Tomcat, but not middle versions

I have an issue compiling several JSP files in Tomcat < 5.5.26 and Tomcat 7, but not in Tomcat 5.5.26 through 6.0.32. Ultimately, I'm going to fix the underlying problem in the JSP files (it will take some time), but I would like to get some community input as to the issue from a Tomcat / JDT Compiler standpoint.

Originally, I discovered some time ago that these JSP files would NOT compile in Tomcat 5.5.25 or below, throwing the following error:

"The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit."

However, this problem did NOT occur with the EXACT same JSP code in Tomcat 5.5.26 or higher, which compiled my JSP files without error. So I tested in Tomcat 6.0.0 through 6.0.32, and no versions of Tomcat 6 ever threw this error. They all compiled my JSP files just fine. Also, Glassfish, WebSphere and WebLogic had no issues compiling my JSPs on any version, so I saw no need to fix the JSP files (although, ultimately they will be fixed when I improve the codebase). However, I wanted to understand better.

I discovered that the Eclipse JDT compiler used in Tomcat was version 3.1.1 in Tomcat 5.5.25, but upgraded to 3.3.1 with Tomcat 5.5.26. I didn't think this could be coincidence. I looked at Tomcat 6 and discovered that the very first version of Tomcat 6 had version 3.2.0 of the JDT compiler.  I came to the conclusion that a bug was fixed in the JDT compiler some time between versions 3.1.1 and 3.2.0 that resolved my problem, but I was never actually able to find that bug. Then, when testing Tomcat 7.0.12 the other day for production readiness, I discovered that the error had resurfaced.

None of my JSPs will compile in Tomcat 7.0.12. They throw the exact same error. Looking at the source distribution, I discovered that Tomcat 7.0.12 is using JDT compiler version 3.6.2, a much newer version. So, either the problem has resurfaced in the JDT compiler, or the problem was never in the JDT compiler at all, but was instead in Tomcat.

Any input? Like I said, I am going to fix these JSPs, but I would like to know what the heck is going on, and why I can compile these JSPs in every application server except Tomcat < 5.5.26, Tomcat 7 and JBoss 6.

Thanks in advance for any input,

Nick

Re: Issue compiling a JSP in old and new versions of Tomcat, but not middle versions

Posted by Konstantin Kolinko <kn...@gmail.com>.
2011/4/7 Christopher Schultz <ch...@christopherschultz.net>:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Nick,
>
> On 4/7/2011 11:20 AM, Nick Williams wrote:
>> Originally, I discovered some time ago that these JSP files would NOT
>> compile in Tomcat 5.5.25 or below, throwing the following error:
>>
>> "The code of method _jspService(HttpServletRequest,
>> HttpServletResponse) is exceeding the 65535 bytes limit."
>
> Huge JSPs are very sensitive to the exact version of Jasper (Tomcat's
> JSP engine) and the compiler (JDT) that you are using. Certain changes
> in the implementation of Jasper may or may not generate methods with too
> much bytecode, and certain versions of the compiler may have different
> bytecode optimizations that can be performed and might get you under the
> 64k method-size ceiling.
>

Note, that there are a number of options available to Jasper, that
affect code generation. It might be that some of them will help you.

Some options cause Jasper to generate less code, but longer textual
string, etc. (Might not be a silver bullet, because there are limits
on the length of strings and so on).

See comments in conf/web.xml and
http://tomcat.apache.org/tomcat-6.0-doc/jasper-howto.html


>> None of my JSPs will compile in Tomcat 7.0.12. They throw the exact
>> same error. Looking at the source distribution, I discovered that
>> Tomcat 7.0.12 is using JDT compiler version 3.6.2, a much newer
>> version. So, either the problem has resurfaced in the JDT compiler,
>> or the problem was never in the JDT compiler at all, but was instead
>> in Tomcat.
>
> It's likely a combination of the two.
>
>> Any input? Like I said, I am going to fix these JSPs, but I would
>> like to know what the heck is going on

Anyway, the generated java files are present in the work folder. You
may look at what they are.

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Issue compiling a JSP in old and new versions of Tomcat, but not middle versions

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nick,

On 4/7/2011 11:20 AM, Nick Williams wrote:
> Originally, I discovered some time ago that these JSP files would NOT
> compile in Tomcat 5.5.25 or below, throwing the following error:
> 
> "The code of method _jspService(HttpServletRequest,
> HttpServletResponse) is exceeding the 65535 bytes limit."

Huge JSPs are very sensitive to the exact version of Jasper (Tomcat's
JSP engine) and the compiler (JDT) that you are using. Certain changes
in the implementation of Jasper may or may not generate methods with too
much bytecode, and certain versions of the compiler may have different
bytecode optimizations that can be performed and might get you under the
64k method-size ceiling.

> None of my JSPs will compile in Tomcat 7.0.12. They throw the exact
> same error. Looking at the source distribution, I discovered that
> Tomcat 7.0.12 is using JDT compiler version 3.6.2, a much newer
> version. So, either the problem has resurfaced in the JDT compiler,
> or the problem was never in the JDT compiler at all, but was instead
> in Tomcat.

It's likely a combination of the two.

> Any input? Like I said, I am going to fix these JSPs, but I would
> like to know what the heck is going on, and why I can compile these
> JSPs in every application server except Tomcat < 5.5.26, Tomcat 7 and
> JBoss 6.

JBoss uses Tomcat internally, and I suspect that it also uses Jasper as
well. Other vendors' servers may have features that either reduce the
amount of code generated for your JSP, or split your JSP into several
methods. Tomcat evidently does not do this kind of thing. Or, it's just
dumb luck.

I don't know any way for Jasper to know how much bytecode a particular
method will generate. You can't even do things like count lines of
generated-source because a line of source code can be arbitrarily
complex, so you just have to guess. I suppose if Jasper were to compile
on-the-fly and take evasive action when the bytecode count gets
sufficiently high, it would be possible.

Patches are always welcome :)

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2d/coACgkQ9CaO5/Lv0PAIBACfZVhnPGgk2JBQv7AXMgKtqYVk
G8IAn1Uqc6od40EWHet9AK8Rd7TTME0k
=DJH/
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org