Missing error information when included jsp page has errors
-----------------------------------------------------------
Key: TILES-230
URL: https://issues.apache.org/struts/browse/TILES-230
Project: Tiles
Issue Type: Bug
Components: tiles-jsp (jsp support)
Affects Versions: 2.0.5
Environment: windows xp, IBM RAD 7, Websphere App Server 5.1
Reporter: Peter Paul Bakker
When an included jsp in a tile template contains errors, valuable context
information from the original exception is lost and does not appear in the
logging.
We created a temp. fix by adding the relevant error information directly in the
message of the exception. The original ServletException contains the
information in the getMessage() and the internal rootCause member variable.
The essential information is: "(7,0) No such tag textField in the tag library
imported with prefix s", but this is lost.
>From the 2.0.5 code:
It starts in JspUtil.doInclude(PageContext, String, boolean) line: 102
/**
* Includes an URI in the JSP response.
*
* @param pageContext The page context to use.
* @param uri The URI to include.
* @param flush <code>true</code> means that the buffer should be flushed at
* the end of this operation
* @throws JspException If an underlying exception happens.
*/
public static void doInclude(PageContext pageContext, String uri, boolean
flush)
throws JspException {
...
try {
pageContext.include(uri);
} catch (IOException e) {
throw new JspException("IOException while including page.", e);
} catch (ServletException e) {
>>> line 102: throw new JspException("ServletException while including page.",
>>> e);
}
}
Next stack frame: JspTilesRequestContext
/** [EMAIL PROTECTED] */
public void include(String path) throws IOException {
try {
JspUtil.doInclude(pageContext, path, false);
} catch (JspException e) {
LOG.error("JSPException while including path '" + path + "'. ", e);
throw new IOException("JSPException while including path '" + path
+ "'. " + e.getMessage());
}
}
Here, the JspException contains:
+ cause: javax.servlet.jsp.JspException: ServletException while including page.
+ detailMessage: ServletException while including page.
+ rootCause: javax.servlet.ServletException:
/WEB-INF/starlight/workflow/addCustomerInformation.jsp(7,0) No such tag
textField in the tag library imported with prefix s
The IOException contians:
+ cause: java.io.IOException: JSPException while including path
'/WEB-INF/starlight/workflow/addCustomerInformation.jsp'. ServletException
while including page.
+ detailMessage: JSPException while including path
'/WEB-INF/starlight/workflow/addCustomerInformation.jsp'. ServletException
while including page.
The essential info is lost in the IOException and is also not logged in the
toString() method of the JSP exception.
=============
Our quick fix is the following:
try {
pageContext.include(uri);
} catch (IOException e) {
throw new JspException("IOException while including page.", e);
} catch (ServletException e) {
// added the getMessage, because the root cause gets lost when the
JSPException bubbles up.
throw new JspException("ServletException while including page: " +
e.getMessage(), e);
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.