Bug 36127

Summary: validation with xerces 2.7.1
Product: Tomcat 5 Reporter: Florent BENOIT <florent.benoit>
Component: JasperAssignee: Tomcat Developers Mailing List <dev>
Severity: normal    
Priority: P2    
Version: 5.5.9   
Target Milestone: ---   
Hardware: All   
OS: All   
URL: http://pastebin.com/333771
Attachments: Example reproducing the problem
Patch for fixing this issue

Description Florent BENOIT 2005-08-10 17:28:54 UTC

When using Tomcat with the last xerces version (2.7.1), there is a problem on
jsp validation. (Note that next Tomcat version will have also 2.7.1 version (as
it was put in the changelog) in current CVS tree).

One way to fix it is in the org/apache/jasper/compiler/JspDocumentParser.java file.
By replacing :


by :


(Patch at the end)

Note that the setValidating() method is also used by digester which is used by
Tomcat as other places.
See getFactory() method.

I provide a sample (you could extract the xml snippet if you want to test it in
Tomcat directly without the sample Class).
I tried this example with Sun JDK 1.4.2_08, JDK 5_update4 and with xerces 2.6.2
and 2.7.1 (with endorsed java -Djava.endorsed.dirs=...) and with 
factory.setValidating(validating); it works in all cases. (like in Digester).

It will be fine if it could be fixed in CVS for next Tomcat version.



Index: JspDocumentParser.java
RCS file:
retrieving revision 1.84
diff -u -r1.84 JspDocumentParser.java
--- JspDocumentParser.java	30 Mar 2005 20:27:22 -0000	1.84
+++ JspDocumentParser.java	10 Aug 2005 15:22:04 -0000
@@ -1370,9 +1370,10 @@
-        factory.setFeature(
-            "http://xml.org/sax/features/validation",
-            validating);
+        factory.setValidating(validating);
         // Configure the parser
         SAXParser saxParser = factory.newSAXParser();

         // Configure the parser
         SAXParser saxParser = factory.newSAXParser();
Comment 1 Florent BENOIT 2005-08-10 17:30:45 UTC
Created attachment 15995 [details]
Example reproducing the problem

Class reproducing the jasper problem with xerces 2.7.1

java -Djava.endorsed.dirs=<path with xerces2.7.1 jars inside> sax.Sax
Comment 2 Florent BENOIT 2005-08-10 17:33:39 UTC
Created attachment 15996 [details]
Patch for fixing this issue

Patch for fixing this issue (with xerces 2.7.1), also it works with other
xerces version and JDK
Comment 3 Remy Maucherat 2005-08-10 18:00:56 UTC
Wouldn't it be better to set both ?
Comment 4 Florent BENOIT 2005-08-10 18:13:32 UTC
It works for me only with one thing.
Also, only xml with DTD have to be validated in this case of JSP (no schema).
(Section JSP 6.2.4)

So I think the use of only factory.setValidating(validating); will be OK.


Comment 5 Remy Maucherat 2005-08-11 14:01:10 UTC
It's actually section 6.2.4. I think the change is reasonable, but I'll leave
the old code in commented out.