The FirstPassVisitor in org.apache.jasper.compiler.PageDataImpl adds all attributes (except "version") of jsp:root elements of included JSPs to jsp:root of expanded XML view. The expanded XML view is thus, often malformed. Any entity, such as a TagLibraryValidator, that tries to subsequently parse the malformed expanded XML view, fails. For example: main.jspx (using Jakarta Taglibs "standard" JSTL impl): -------------------------------------------------------------- <?xml version="1.0" encoding="UTF-8"?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jsp/jstl/core" version="2.0" > <jsp:directive.include file="one.jspx"/> </jsp:root> where one.jspx is: ---------------------- <?xml version="1.0" encoding="UTF-8"?> <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0" /> gives: <top-of-stack-trace> org.apache.jasper.JasperException: <h3>Validation error messages from TagLibraryValidator for c</h3><p>null: org.xml.sax.SAXParseException: Attribute "jsp" bound to namespace "http://www.w3.org/2000/xmlns/" was already specified for element "jsp:root".</p> </top-of-stack-trace> as, in this scenario, attribute xmlns:jsp gets added twice. [Problem reported by "Dino Klein" <zagzag@speakeasy.net> on taglibs-dev@j.a.o] I'm proposing a patch that causes FirstPassVisitor to only add those attributes to the jsp:root of the expanded XML view that have not been already added. Index: PageDataImpl.java =================================================================== RCS file: /usr/local/cvsroot/apache/jakarta-tomcat-5.0.28-src/jakarta-tomcat- jasper/jasper2/src/share/org/apache/jasper/compiler/PageDataImpl.java,v retrieving revision 1.1 diff -c -r1.1 PageDataImpl.java *** PageDataImpl.java 7 Jun 2005 02:29:52 -0000 1.1 --- PageDataImpl.java 7 Jun 2005 02:33:19 -0000 *************** *** 205,218 **** if (attrs != null) { int len = attrs.getLength(); for (int i=0; i<len; i++) { ! if ("version".equals(attrs.getQName(i))) { continue; } ! rootAttrs.addAttribute(attrs.getURI(i), attrs.getLocalName(i), ! attrs.getQName(i), attrs.getType(i), attrs.getValue(i)); } } } --- 205,221 ---- if (attrs != null) { int len = attrs.getLength(); for (int i=0; i<len; i++) { ! String qName = attrs.getQName(i); ! if ("version".equals(qName)) { continue; } ! if (rootAttrs.getIndex(qName) == -1) { ! rootAttrs.addAttribute(attrs.getURI(i), attrs.getLocalName(i), ! qName, attrs.getType(i), attrs.getValue(i)); + } } } }
This is still a problem with 5.5.12. Perhaps the version in this bug should be changed in order to reflect that.
Updated versions (which by the way anyone can do), will fix right now.
Fixed.
is this really fixed? i have tomcat 5.5.15 and get the exact same error: org.apache.jasper.JasperException: Error on line 1 of document : Attribute "star" bound to namespace "http://www.w3.org/2000/xmlns/" was already specified for element "star:content-block". Nested exception: Attribute "star" bound to namespace "http://www.w3.org/2000/xmlns/" was already specified for element "star:content-block". thanks. nn
It looks fixed in 5.5.16. Is it really? Should the bug be closed? Fabio.
The duplicate has more info on how to reproduce. *** This bug has been marked as a duplicate of 39557 ***