Bug 38897 - Invalid TLDs receive cryptic error
Summary: Invalid TLDs receive cryptic error
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Jasper (show other bugs)
Version: Nightly Build
Hardware: Macintosh Mac OS X 10.4
: P3 normal with 2 votes (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-08 18:33 UTC by Adam Winer
Modified: 2009-07-07 07:04 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Winer 2006-03-08 18:33:00 UTC
Install a JSP 1.2 TLD that is missing the <tlib-version>.  Invalid, yes.
However, all you get is the following stack trace:

org.apache.jasper.JasperException: /components/panelGroup.jspx(6,70) Could not
add one or more tag libraries.
	org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39)
	org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405)
	org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:86)
	org.apache.jasper.compiler.JspDocumentParser.parse(JspDocumentParser.java:211)
	org.apache.jasper.compiler.ParserController.doParse(ParserController.java:196)
	org.apache.jasper.compiler.ParserController.parse(ParserController.java:100)
	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:155)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
	com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:322)
	com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:130)
(etc...)


The actual and completely helpful error is swallowed and does not appear in the
log or on the console;  its stack trace, from adding  (omitting duplicates):

org.apache.jasper.JasperException: Unable to read TLD "META-INF/afu.tld" from
JAR file
"file:/Users/adamwiner/Work/cvs/tomcat5/build/build/webapps/ard/WEB-INF/lib/adf-unified-impl-11-m3-SNAPSHOT.jar":
org.apache.jasper.JasperException: Mandatory TLD element missing or empty:
tlib-version
        at
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:50)
        at
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
        at
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:179)
        at
org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:181)
        at
org.apache.jasper.compiler.JspDocumentParser.getTaglibInfo(JspDocumentParser.java:1260)
        at
org.apache.jasper.compiler.JspDocumentParser.startPrefixMapping(JspDocumentParser.java:767)
        at
org.apache.xerces.parsers.AbstractSAXParser.startNamespaceMapping(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
        at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
        at
org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown
Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
        at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:375)
        at
org.apache.jasper.compiler.JspDocumentParser.parse(JspDocumentParser.java:176)
Comment 1 Yoav Shapira 2006-06-15 19:26:11 UTC
So where did you get the useful error text from?
Comment 2 Adam Winer 2006-06-15 19:39:00 UTC
I rebuilt a version of Tomcat and added a printStackTrace() to at least see the buried message.
Comment 3 Yoav Shapira 2006-06-15 19:52:19 UTC
Where did you add that printStackTrace call?
Comment 4 Adam Winer 2006-06-15 20:25:05 UTC
I don't remember, to be honest - this was three months ago.  I'd guess DefaultErrorHandler.jspError(), but 
that's just a guess.
Comment 5 Michiel Meeuwissen 2007-08-03 04:38:50 UTC
I think this bug may be fixed in tomcat 6.

I get helpful messages like:
org.apache.jasper.JasperException: File "/META-INF/tags/mm/u/option.tagx" not found
Comment 6 J 2007-08-06 15:14:17 UTC
I had a very similar problem in Tomcat 6.0.13 that was caused by a missing tld 
file in my deployment. The stacktrace was the same as in the first comment and 
did not indicate which tag library caused the problem. I used the following 
patch to track down the problem and log the cause of the exception:

Index: java/org/apache/jasper/compiler/JspDocumentParser.java
===================================================================
--- java/org/apache/jasper/compiler/JspDocumentParser.java      (revision 
563257)
+++ java/org/apache/jasper/compiler/JspDocumentParser.java      (working copy)
@@ -214,7 +214,8 @@
             jspDocParser.err.jspError
                 (new Mark(jspDocParser.ctxt, path, e.getLineNumber(),
                           e.getColumnNumber()),
-                 e.getMessage());
+                 e.getMessage(),
+                 e);
         } catch (Exception e) {
             jspDocParser.err.jspError(e);
         }
Index: java/org/apache/jasper/compiler/ErrorDispatcher.java
===================================================================
--- java/org/apache/jasper/compiler/ErrorDispatcher.java        (revision 
563257)
+++ java/org/apache/jasper/compiler/ErrorDispatcher.java        (working copy)
@@ -225,6 +225,22 @@
      * resource bundle for localized error messages, it is used as the error
      * message.
      *
+     * @param where Error location
+     * @param errCode Error code
+     * @param exception Exception
+     */
+
+    public void jspError(Mark where, String errCode, Exception exception)
+                throws JasperException {
+        dispatch(where, errCode, null, exception);
+    }
+    /*
+     * Dispatches the given JSP parse error to the configured error handler.
+     *
+     * The given error code is localized. If it is not found in the
+     * resource bundle for localized error messages, it is used as the error
+     * message.
+     *
      * @param n Node that caused the error
      * @param errCode Error code
      * @param arg1 First argument for parametric replacement
Comment 7 Mark Thomas 2009-07-05 06:44:29 UTC
Testing with the latest 5.5.x:

Missing <tlib-version> gets:
Mandatory TLD element missing or empty: tlib-version

Missing TLD files gives:
The absolute uri: XXXXX cannot be resolved in either web.xml or the jar files deployed with this application

This is much better than it was when this bug was first raised but the first message could tell you which TLD has the problem. I've patched trunk and proposed the fix for 5.5.x and 6.0.x
Comment 8 Mark Thomas 2009-07-07 06:44:13 UTC
Fixed in trunk and will be in 6.0.21 onwards.
Comment 9 Mark Thomas 2009-07-07 07:04:25 UTC
This has been fixed in trunk and will be included in 5.5.28 onwards.