↓ Skip to main content

Too long method size

·137 words·1 min
Sergii Zolotarov
Author
Sergii Zolotarov
Twenty years of Java, from Kyiv to Leeuwarden. Currently at Booking.com

A few days ago I saw a strange and funny message while viewing a very long jsp


SEVERE: Servlet.service() for servlet jsp threw exception
org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 69 in the generated java file
The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit

Stacktrace:
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
    at org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)

It appears this error has a very ancient history :) It surprises me that the error has not been fixed since. This is the usual problem of java - in order to stay backward compatible even its own bugs have to live on to next JDK versions.

The only simple solution I found is to split the page and use .


First published on the old anydoby.com blog on 2008-02-07.