1

I was encountering An error occurred at line: 384 in the generated java file The code of method

_jspService(HttpServletRequest, HttpServletResponse)

is exceeding the 65535 bytes limit.

I have tried several solution around the web and issue still persists.

I am using Jboss-5.1.0 GA as the server.

Here are the stacktrace of the error.

An error occurred at line: 384 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:439)
            at org.apache.jasper.compiler.Compiler.compile(Compiler.java:335)
            at org.apache.jasper.compiler.Compiler.compile(Compiler.java:313)
            at org.apache.jasper.compiler.Compiler.compile(Compiler.java:300)
            at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:585)
            at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:312)
            at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:322)
            at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
            at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
            at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:638)
            at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:543)
            at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:480)
            at com.liferay.portlet.PortletRequestDispatcherImpl.dispatch(PortletRequestDispatcherImpl.java:307)
            at com.liferay.portlet.PortletRequestDispatcherImpl.include(PortletRequestDispatcherImpl.java:115)
            at com.liferay.portal.struts.PortletRequestProcessor.doInclude(PortletRequestProcessor.java:284)
            at com.liferay.portal.struts.PortletRequestProcessor.doForward(PortletRequestProcessor.java:255)
Jay Thakkar
  • 1,274
  • 9
  • 18

1 Answers1

4

Your JSP is too large / too complicated. You need to refactor it

We tried refactoring but its not working are there any alternate solutions?

No.

The problem is that there is a hard limit imposed by the Java virtual machine specification on the number of bytes of bytecode in a compiled Java method. (Specifically, the classfile format uses a 16 bit number as the sides of the method's code array.)

Java compilers are not able to automatically split a method that is too large into sub-methods. You have to do it yourself at the source code level.

With JSPs, the JSP compiler translates each JSP into a class with a single (large) Java method, unless you can refactor it by either moving some of logic into separate methods, classes or ... JSPs using "dynamic includes"; see https://stackoverflow.com/a/5484509/139985.)

Stephen C
  • 669,072
  • 92
  • 771
  • 1,162
  • Thanks @Stephen for the reply..when I try to use dynamic include instead of include directive it is throwing a classnotfoundexception. can you please suggest me any other alternative ways. – Jeevana Anubrolu Oct 24 '19 at 13:09
  • I don't know any other alternatives apart from the two that I have mentioned. I suggest you figure out **why** you are getting `ClassNotFoundException` and try to fix that. – Stephen C Jan 03 '22 at 00:06