Bug 40104 - Jasper picking up incorrect file in JspServletWrapper.java context dump
Summary: Jasper picking up incorrect file in JspServletWrapper.java context dump
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Jasper (show other bugs)
Version: 5.5.17
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-24 17:09 UTC by Darryl Miles
Modified: 2007-01-14 14:49 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Darryl Miles 2006-07-24 17:09:26 UTC
org.apache.jasper.JasperException: Exception in JSP: /WEB-INF/template/debug.jspf:4

1: <%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" isErrorPage="true"%>
2: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
3: <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
4: <%@ taglib prefix="g" uri="http://domain.com/taglibs/generic-0.1" %>
5: <jsp:directive.page import="java.io.*"/>
6: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
7: <html>

Stacktrace:
        at
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
        at
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
...SNIP...


The exception correctly reports the point of the error:
/WEB-INF/template/debug.jspf:4

But the 7 lines of context are actually from the file
/WEB-INF/template/errorpage.jsp


jasper/jasper2/src/share/org/apache/jasper/servlet/JspServletWrapper.java:471 uses:

              // Read both files in, so we can inspect them
              String[] jspLines = readFile
                  (this.ctxt.getResourceAsStream(this.ctxt.getJspFile()));

              String[] javaLines = readFile
                  (new FileInputStream(this.ctxt.getServletJavaFileName()));

Is that correctly picking up the context from the exception information ?

The page debuig.jspf is added to a master page with:

<%@ include file="/WEB-INF/template/debug.jspf" %>


The exception looks like it created here:

return new JasperException(
                                           "Exception in JSP: " +
detail.getJspFileName() + ":" +
                                           jspLineNumber + "\n\n" + buffer +
"\n\nStacktrace:", ex);

That uses detail.getJspFileName() not this.ctxt.getServletJavaFileName().

I'm thinking both cases should use detail.getJspFileName().


I have ErrorPages setup to /WEB-INF/template/errorpage.jsp.
Comment 1 Darryl Miles 2006-07-24 17:13:42 UTC
Opps not this.ctxt.getServletJavaFileName().

I meant to say I think this.ctxt.getJspFile() should be detail.getJspFileName()
(or the equalvalent of)
Comment 2 Mark Thomas 2007-01-14 14:49:07 UTC
This has been fixed in svn and will be included in 5.5.21 onwards.