Summary: | 6.0.22RC: ArrayIndexOutOfBoundsException from Jasper when compilation error inside a CDATA block | ||
---|---|---|---|
Product: | Tomcat 6 | Reporter: | Konstantin Kolinko <knst.kolinko> |
Component: | Jasper | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | rawatsaurav |
Priority: | P2 | ||
Version: | 6.0.20 | ||
Target Milestone: | default | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Attachments: |
/webapps/examples/WEB-INF/tags/panel.tagx
/webapps/examples/jsp/jsp2/jspx/basic.jspx |
Description
Konstantin Kolinko
2010-01-06 19:40:54 UTC
Created attachment 24809 [details] /webapps/examples/jsp/jsp2/jspx/basic.jspx One more example - a JSP page. Location: /webapps/examples/jsp/jsp2/jspx/basic.jspx HTTP Address: http://localhost:8080/examples/jsp/jsp2/jspx/basic.jspx Displays java.lang.ArrayIndexOutOfBoundsException: 57 Reproducible in 6.0.20. So, it is not a regression in the current 6.0.x. If anyone encounters this, one way to find where it failed is to search in the /work directory for a *.java file that does not have *.class file of the same name. That matches to a jsp or tag file that failed to compile. This is not a Tomcat but, but a bug in the SAX Parser provided by the JDK. Local testing shows: 1.5.0_22_x64 - works 1.6.0_16_x64 - ArrayIndexOutOfBoundsException 1.7.0_b76_x64 - ArrayIndexOutOfBoundsException The bug is that in LexicalHandler.startCDATA() the Locator points to the end of the CDATA section rather than the start. This will always lead to misleading JSP snippets any may result in an ArrayIndexOutOfBoundsException if the CDATA block is close enough to the end of the JSP file. I have reported the bug to Sun and am awaiting a public bug number. I'll update this issue when I get it. You can use Xerces 2.9.1 to override the default SAX Parser provided by the JDK to work around this bug if required. I looked at providing a work around in Tomcat but correctly handling the behaviour of different JDKs with and without Xerces overriding was getting just too messy to be worth while. Reopening. Even if we cannot fix/workaround the root cause, at least we can add bounds checking to JavacErrorDetail constructor. The sad outcome of this issue was that when this ArrayIndexOutOfBoundsException error occurs, there is no information in the stack trace about what JSP or Tag file caused this issue. Even if we cannot display the source lines, it would be nice to display all other details. As much as it pains me to have to add a workaround in Tomcat for a Java bug you have a fair point that hiding the compilation error is a nasty side-effect. Workaround added to 7.0.x and proposed for 6.0.x The workaround has been applied to 6.0.x and will be included in 6.0.26 onwards. |