DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5739>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5739

Struts fails silently in too many places





------- Additional Comments From [EMAIL PROTECTED]  2004-02-11 07:45 -------
Attached are the changed ActionServlet.java and XercesParser.java files. Below 
is the diff that shows what was added to activate the schema validation:

--- ActionServlet.java.old      2004-01-10 13:03:38.000000000 -0800
+++ ActionServlet.java  2004-01-24 14:01:50.000000000 -0800
@@ -221,6 +221,11 @@
*/
     protected String config = "/WEB-INF/struts-config.xml";
 
+       /**
+     * <p>Location of schema validation file for all struts-config.xml related 
files</p>
+        *
+     */
+       protected String schemaLocation = "/WEB-INF/struts-config-schema.xsd";
 
     /**
      * <p>The Digester used to produce ModuleConfig objects from a
@@ -961,6 +966,13 @@
 
         this.addRuleSets();
 
+               try {
+                       URL schemaUrl = getServletContext().getResource
(schemaLocation);
+                       configDigester.setSchema(schemaUrl.toExternalForm()); 
+               } catch (MalformedURLException mue) {
+            handleConfigException(schemaLocation, mue);
+               }
+
         // Return the completely configured Digester instance
         return (configDigester);
     }

The change to XercesParser.java which is in the nightly Commons Digester 
packages is needed if you are using Xerces 2.2 or greater:

--- XercesParser.java.old       2004-02-09 03:39:14.000000000 -0800
+++ XercesParser.java   2004-01-24 15:40:47.000000000 -0800
@@ -172,12 +172,15 @@
             versionNumber = getXercesVersion();
             version = new Float( versionNumber ).floatValue();
         }
-
         // Note: 2.2 is completely broken (with XML Schema). 
-        if (version > 2.1) {
 
+        // Tested with Xerces 2.6. Looks ok
+        if (version > 2.2) {
             configureXerces(factory);
-            return factory.newSAXParser();
+                       SAXParser newParser = factory.newSAXParser();
+                       // Test 2.6 with schema validation
+                       configureOldXerces(newParser, properties);
+            return newParser;
         } else {
             SAXParser parser = factory.newSAXParser();
             configureOldXerces(parser,properties);


Build and replace both the struts.jar and commons-digester.jar files in your 
application, and add struts-config-schema.xsd to the WEB-INF folder. I used the 
struts-example to test this by adding two form beans with the same name, two 
Actions with the same path, not defining a name for an ActionForm in struts-
config.xml. When Tomcat is started, there will be error messages in the startup 
window.  I've also tested this with my own struts app and it seems to be ok 
too.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to