http://stackoverflow.com/questions/6904117/code-
http://marc.info/?l=struts-user&m=98512887614286&w=2
I am, unfortunately, intimately familiar with this problem.
The problem is that there is a limit on the size of a compiled method in a
Java class file, and that limit is what we’re running up against. Recall
that a JSP page is compiled into a servlet, and into essentially only one
method in that servlet. Hence, if your page contains many, many tags, that
method becomes too big, and up comes the exception that you’re seeing.
There are a couple of (partial) solutions.
1) Break your giant page up into multiple smaller pages and bring them
together at run time using . Note that won’t work,
because that’s a compile-time include, which will get you straight back to
the original problem.
2) Look for places to save on tags. For example, the tag was
recently extended to allow the specification of the text to display, so
that you can replace this:
with this:
If you have a lot of cases of this pattern, it can help quite a bit. In
addition to the tag, some other Struts tags allow the same
shortcut to including the text. Also, you might consider replacing
sequences with if you can build an appropriate
collection up front.
Unfortunately, we can’t use solution (1), because our giant page is almost
entirely one . (Please don’t ask… :-} ) Many of the
tags won’t work if they are on a separate page from the tag
itself. That means I’ve spent quite some time on option (2).
We have several of our own tags, too, so that was the next place for me to
look. I discovered that changing some frequently used tags from extending
BodyTagSupport to extending TagSupport, and marking them with
empty in the .tld file, made a significant
reduction in generated code size. Of course, this is not always feasible,
but it helped us quite a bit.
One other trick is to create custom tags for frequently used groups of
related elements. For example, I created a simple DatePickerTag which is a
Struts-like tag that combines three drop-down boxes for month, day and
year, with the localized strings obtained from the JVM, and the current
values pulled from a bean.
That’s about all I can think of that I’ve tried so far. All our pages are
now within the limit, but one is very close to breaking it. I really want
to put a “do not touch” notice on that file!
Hope this helps.
The size limit in Java for a method is 65535 characters. You need to refactor that code. This website here has a solution. From the Java Spec:
The length of field and method names, field and method descriptors, and other constant string values is limited to 65535 characters by the 16-bit unsigned length item of the CONSTANT_Utf8_info structure (§4.4.7). Note that the limit is on the number of bytes in the encoding and not on the number of encoded characters. UTF-8 encodes some characters using two or three bytes. Thus, strings incorporating multibyte characters are further constrained.
Apparently, this is common with dynamically generated JSP.
And, since you may be blocked at work – here is the recommended solution from that site:
Help your container modularize the code. Try splitting the JSP into several chunks and make dynamic includes instead of static ones. Dynamic includes (jsp:include against %@include) will compile the JSP and then stream the output instead of trying to include all the code into one big method or try catch block.too-large-for-try-block