【问题标题】:How to fix the error The code of method _jspService(HttpServletRequest, HttpServletResponse) is exceeding the 65535 bytes limit Jboss如何修复错误 _jspService(HttpServletRequest, HttpServletResponse) 方法的代码超出了 Jboss 的 65535 字节限制
【发布时间】:2020-02-15 02:15:34
【问题描述】:

我遇到了一个错误发生在生成的java文件中的第384行方法的代码

_jspService(HttpServletRequest, HttpServletResponse)

超过了 65535 字节的限制。

我已经尝试了几种网络解决方案,但问题仍然存在。

我使用 Jboss-5.1.0 GA 作为服务器。

这是错误的堆栈跟踪。

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)

【问题讨论】:

  • 您的 JSP 太大/太复杂。你需要重构它。
  • 我们尝试了重构,但它不起作用是否有任何替代解决方案?

标签: java jsp-tags


【解决方案1】:

您的 JSP 太大/太复杂。你需要重构它

我们尝试了重构,但它不起作用是否有任何替代解决方案?

没有。

问题在于 Java 虚拟机规范对已编译 Java 方法中字节码的字节数施加了硬性限制。 (具体来说,classfile 格式使用 16 位数字作为方法的代码数组的边。)

Java 编译器无法自动将太大的方法拆分为子方法。你必须在源代码级别自己做。

对于 JSP,JSP 编译器将每个 JSP 转换为具有单个(大型)Java 方法的类,除非您可以通过将一些逻辑移动到单独的方法、类或使用“动态包含”的 JSP 来重构它;见https://stackoverflow.com/a/5484509/139985。)

【讨论】:

  • 感谢@Stephen 的回复..当我尝试使用动态包含而不是包含指令时,它会抛出一个 classnotfoundexception。你能建议我任何其他替代方法吗?
  • 我不知道除了我提到的两个之外的任何其他选择。我建议你弄清楚为什么你会收到ClassNotFoundException 并尝试解决这个问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-03-24
  • 2018-06-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-28
相关资源
最近更新 更多