`

编译JSP时出的问题:code too large for try statement

阅读更多
相关链接:
http://topic.csdn.net/t/20041111/20/3544983.html
http://www.iteye.com/post/57265
http://www.javaworld.com.tw/jute/post/view?bid=6&id=34678&sty=3
http://marc.info/?l=struts-user&m=98512887614286&w=2
具体问题:
我的JSP文件太大有300多K,这个主要是因为系统一直在维护,很多人因为各种功能需求对这个JSP做了修改,本来编译和运行都是没有问题的,但奇怪的是我只多加了一段HTML代码就出现了这个问题,说了大家可能不信,我只多加了一个<td>kkkee</td>,就出问题了,代码如下:注释的部分是我加的,加了后就出问题:

  1. <tr>
  2. <tdwidth=""CLASS="fmkey"valign="top">BuCode:</td>
  3. <tdwidth=""class="fmvalue"align="left">
  4. <INPUTTYPE="TEXT"NAME="BuCode"SIZE="23"CLASS="<%=sStyle%>">
  5. </span>
  6. </td>
  7. <td>
  8. <INPUTTYPE="BUTTON"NAME=""VALUE="..."CLASS="btnLook"onClick="openLookupGen(arrSetBuCode,arrGetBuCode,'<%=EusUtil.getPage("lookup.generic.bucode.s")%>',arrBuCodeParam,640,480,'yes')">
  9. sfsfsf
  10. </td>
  11. <!--<td>kkkee</td>-->
  12. </tr>
具体问题如下:

  1. <<2008-12-1110:19:57.750>>(HttpUtil)ErrorMsg:callpage
  2. ExceptionMsg:org.apache.jasper.JasperException:UnabletocompileclassforJSP
  3. Anerroroccurredatline:-1inthejspfile:null
  4. Generatedservleterror:
  5. [javac]Compiling1sourcefile
  6. C:\DOCUME~1\WEIFEN~1\LOCALS~1\Temp\Jetty_0_0_0_0_8080__GeTSmart\Tdec_jsp.java:147:codetoolargefortrystatement
  7. try{
  8. ^
  9. 1error
  10. atorg.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:130)
  11. atorg.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:293)
  12. atorg.apache.jasper.compiler.Compiler.generateClass(Compiler.java:340)
  13. atorg.apache.jasper.compiler.Compiler.compile(Compiler.java:352)
  14. atorg.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:474)
  15. atorg.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:184)
  16. atorg.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
  17. atorg.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
  18. atjavax.servlet.http.HttpServlet.service(HttpServlet.java:853)
  19. atorg.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360)
  20. atorg.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
  21. atorg.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:192)
  22. atorg.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:129)
  23. atcom.gobusiness.eus.util.HttpUtil.callPage(HttpUtil.java:225)
  24. atcom.gobusiness.eus.servlet.CreateDocServlet.doPost(CreateDocServlet.java:365)
  25. atcom.gobusiness.eus.servlet.CreateDocServlet.doGet(CreateDocServlet.java:76)
  26. atjavax.servlet.http.HttpServlet.service(HttpServlet.java:740)
  27. atjavax.servlet.http.HttpServlet.service(HttpServlet.java:853)
  28. atorg.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360)
  29. atorg.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
  30. atorg.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:558)
  31. atorg.mortbay.http.HttpContext.handle(HttpContext.java:1714)
  32. atorg.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:507)
  33. atorg.mortbay.http.HttpContext.handle(HttpContext.java:1664)
  34. atorg.mortbay.http.HttpServer.service(HttpServer.java:863)
  35. atorg.jboss.jetty.Jetty.service(Jetty.java:460)
  36. atorg.mortbay.http.HttpConnection.service(HttpConnection.java:775)
  37. atorg.mortbay.http.HttpConnection.handleNext(HttpConnection.java:939)
  38. atorg.mortbay.http.HttpConnection.handle(HttpConnection.java:792)
  39. atorg.mortbay.http.SocketListener.handleConnection(SocketListener.java:201)
  40. atorg.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
  41. atorg.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)
也有出现这个问题:(Codeofamethodlongerthan65535bytes)
  1. ExceptionMsg:javax.servlet.ServletException:org/apache/jsp/Tdec_jsp(Codeofamethodlongerthan65535bytes)
  2. atorg.apache.jasper.servlet.JspServlet.service(JspServlet.java:249)
  3. atjavax.servlet.http.HttpServlet.service(HttpServlet.java:853)
  4. atorg.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360)
  5. atorg.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
  6. atorg.mortbay.jetty.servlet.Dispatcher.dispatch(Dispatcher.java:192)
  7. atorg.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:129)
  8. atcom.gobusiness.eus.util.HttpUtil.callPage(HttpUtil.java:225)
  9. atcom.gobusiness.eus.servlet.CreateDocServlet.doPost(CreateDocServlet.java:365)
  10. atcom.gobusiness.eus.servlet.CreateDocServlet.doGet(CreateDocServlet.java:76)
  11. atjavax.servlet.http.HttpServlet.service(HttpServlet.java:740)
  12. atjavax.servlet.http.HttpServlet.service(HttpServlet.java:853)
  13. atorg.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:360)
  14. atorg.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:294)
  15. atorg.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:558)
  16. atorg.mortbay.http.HttpContext.handle(HttpContext.java:1714)
  17. atorg.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:507)
  18. atorg.mortbay.http.HttpContext.handle(HttpContext.java:1664)
  19. atorg.mortbay.http.HttpServer.service(HttpServer.java:863)
  20. atorg.jboss.jetty.Jetty.service(Jetty.java:460)
  21. atorg.mortbay.http.HttpConnection.service(HttpConnection.java:775)
  22. atorg.mortbay.http.HttpConnection.handleNext(HttpConnection.java:939)
  23. atorg.mortbay.http.HttpConnection.handle(HttpConnection.java:792)
  24. atorg.mortbay.http.SocketListener.handleConnection(SocketListener.java:201)
  25. atorg.mortbay.util.ThreadedServer.handle(ThreadedServer.java:289)
  26. atorg.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:455)

查了相关的资料:
http://marc.info/?l=struts-user&m=98512887614286&w=2
这个帖子解释的比较清楚,还提供了相关的办法

  1. Theproblemisthatthereisalimitonthesizeofacompiledmethodina
  2. Javaclassfile,andthatlimitiswhatwe'rerunningupagainst.Recall
  3. thataJSPpageiscompiledintoaservlet,andintoessentiallyonlyone
  4. methodinthatservlet.Hence,ifyourpagecontainsmany,manytags,that
  5. methodbecomestoobig,andupcomestheexceptionthatyou'reseeing.

主要原因是JAVA文件中对方法有一个大小限制,最大不超过64K,而我的JSP中编译成SERVLET代码的时候就变成了service方法,
这个方法的大小不能超过64K,当JSP文件太大的时候编译成的serviece方法自然就超过了,所以会提供codetoolargefortrystatement,解决方法有:

  1. Thereareacoupleof(partial)solutions.
  2. 1)Breakyourgiantpageupintomultiplesmallerpagesandbringthem
  3. togetheratruntimeusing<jsp:include>.Notethat<%@include>won'twork,
  4. becausethat'sacompile-timeinclude,whichwillgetyoustraightbackto
  5. theoriginalproblem.
  6. 2)Lookforplacestosaveontags.Forexample,the<html:option>tagwas
  7. recentlyextendedtoallowthespecificationofthetexttodisplay,so
  8. thatyoucanreplacethis:
  9. <html:option...><bean:messagekey="foo"/></html:option>
  10. withthis:
  11. <html:option...key="foo"/>

主要有两个解决方法:一个是拆分成多个JSP文件,使用JSP:INCLUDE命令而不是使用<%@INCLUDE%>命令。
第二个是针对使用JSTL或自定义标签的情况,尽量使用产生代码少一些的标签。

在帖子:http://www.iteye.com/post/57265
提到WEBLOG解决了这个问题:
  1. weblogic9解决了这个问题,发布在他上面就不会有任何问题了。我试过了。这个问题也困扰了我们项目组很久。
这个我没有试过。
分享到:
评论

相关推荐

    Value too large for defined data type 解决办法

    在Linux环境下进行文件操作时,可能会遇到一个名为“Value too large for defined data type”的错误。这一问题通常发生在使用`ls`或`find`命令来查看大于2GB(即2^31字节)的文件时。虽然现代操作系统理论上支持...

    DELPHI7编译出错提示内存:RLINK32.dll出错

    delphi7编译慢 或linking阶段会出错 经常会出现内存泄漏或不足 或RLink32.DLL访问出错 直接把bolndmm.dll与rlink32.dll拷贝至delphi7下的bin目录中可以调试了 按网友的说法 新版的内存管理器或连接器 bolndmm.dll...

    E-Code Explorer 0.86正式版 (易语言反编译工具)

    《E-Code Explorer 0.86正式版:易语言反编译利器解析》 在IT领域,软件开发工具的多样性使得程序员们能够更高效地完成工作。其中,易语言作为一款面向中国用户的编程语言,以其简洁易懂的语法赢得了众多开发者喜爱...

    JSP连接mysql:JDBC驱动5.1

    将JSP与MySQL相结合,可以构建出高效且可扩展的Web应用程序。本篇文章将深入讲解如何使用JDBC(Java Database Connectivity)驱动程序5.1版本在JSP中连接到MySQL数据库。 首先,我们要了解JDBC驱动程序的作用。JDBC...

    5个方法解决keil全部编译的问题

    ### 5个方法解决Keil全部编译的问题 在嵌入式系统开发过程中,使用Keil作为集成开发环境(IDE)是非常常见的选择。然而,在实际使用过程中,有时会遇到一个令人头疼的问题——无论何时编译工程,Keil总是执行全部...

    .net dll反编译工具

    所以在下载来的,不能完成反编译出源码,要看源码的最好是在网站编译,下面有链接链接: http://www.remotesoft.com/salamander/ http://www.remotesoft.com/salamander/obfuscator/try.html Remotesoft .NET Explorer ...

    CodeWarrior Development Studio for S12(X) V5.1.

    CodeWarrior Development Studio for S12(X) V5.1.

    jsp页面加载时提示loading

    解决"jsp页面加载时提示loading"的问题需要从多方面进行排查和优化,包括页面内容优化、服务器性能提升、网络条件改善、代码错误检查、缓存策略调整、服务器配置优化、数据库性能优化、AJAX请求优化、JavaScript脚本...

    jsp培训jsp培训jsp培训jsp培训jsp培训

    在进行JSP培训时,通常会涵盖以下几个方面: 1. **基础概念**:讲解JSP的原理、结构以及与其他Web技术的关系。 2. **JSP语法**:深入理解JSP的各种元素和指令,以及如何使用它们来创建动态页面。 3. **EL和JSTL**:...

    Telerik kendo ui for JSP Demo

    Telerik kendo ui for JSP Demo。Kendo UI的for JSP版本,整个B/S工程,后台技术是spring+hibernate。 如果用kendo ui做前台js呈现,这个非常值得一看。因为JSP标签库,最终编译后还是生成了js的代码,有利于调试...

    现代编译原理(虎书)课后答案

    《现代编译原理》(通常被称为“虎书”),是由著名计算机科学家Alfred V. Aho、Monica S. Lam、Ravi Sethi和Jeffrey D. Ullman合著的经典教材,它深入浅出地介绍了编译器设计的各个方面。这本书是许多计算机科学...

    完整图书管理系统(JSP+MySQL)

    《全面解析JSP+MySQL构建图书管理系统》 在IT领域,构建信息管理系统是常见的实践,尤其对于初学者来说,图书管理系统是一个很好的学习项目。本文将深入探讨如何利用JSP(JavaServer Pages)技术和MySQL数据库来...

    python反编译工具合集

    Python反编译是将已经编译过的Python字节码(.pyc文件)转换回源代码(.py文件)的过程,这对于理解闭源代码、学习他人代码或逆向工程等场景非常有用。以下是一些关于Python反编译工具的知识点: 1. **什么是Python...

    apk反编译工具

    10. **法律问题**:在进行APK反编译时,必须确保遵循版权法和用户协议。未经授权访问或修改他人的应用代码可能涉及侵权行为,因此在进行此类操作前应谨慎行事。 综上所述,APK反编译工具是Android生态系统中重要的...

    JSP网页模板JSP网页模板JSP网页模板

    4. **性能优化**:通过预编译JSP页面,可以减少服务器端的解析时间,提高响应速度。 **四、实际应用** 在实际开发中,JSP模板常用于构建企业级Web应用,如电子商务平台、内容管理系统、在线教育系统等。例如,...

    编译原理课后习题答案

    2. **交叉编译:** - 描述:在一个平台上编译生成另一个平台上的可执行代码。 - 用途:适用于不同架构间的目标代码生成。 3. **自展:** - 描述:逐步扩展核心语言的过程,从简单的语言开始,逐步添加新特性,...

    通过JSP将数据库中的数据显示到网页上

    此外,使用预编译的`PreparedStatement`代替`Statement`可以防止SQL注入攻击。 总结: 通过JSP将数据库中的数据显示到网页上,主要涉及以下几个关键步骤: 1. 配置JDBC连接,包括数据库URL、用户名和密码。 2. 使用...

    C# 动态编译文本框里的代码

    在C#编程环境中,动态编译是通过System.CodeDom.Compiler命名空间提供的类来实现的,这使得我们可以在程序运行时动态地创建、编译和执行源代码。这种能力对于构建小型编译器或者代码解释器非常有用,尤其适用于需要...

    c#动态编译生成

    在C#编程中,动态编译是一个非常有用的特性,它允许程序在运行时生成和编译代码。这种技术主要用于各种场景,例如插件系统、代码生成、自动化测试等。本篇将详细介绍两种C#中实现动态编译的方法,并通过一个名为`...

    反编译classes.dex工具

    当使用Smali工具(如baksmali)反编译`classes.dex`时,它会将字节码转换为人类可读的Smali代码。 4. **baksmali.jar**:这是Smali反编译器的二进制版本。它能将`classes.dex`文件分解为一系列Smali源代码文件,...

Global site tag (gtag.js) - Google Analytics