You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by js...@apache.org on 2006/06/01 02:14:47 UTC

svn commit: r410704 - /geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java

Author: jsisson
Date: Wed May 31 17:14:47 2006
New Revision: 410704

URL: http://svn.apache.org/viewvc?rev=410704&view=rev
Log:
GERONIMO-2069 - o.a.g.system.configuration.LocalAttributeManager.load() does not setErrorHandler when parsing.  Improved error logging, Users will now get a more useful error giving the file name, line and column number if they had a bad config.xml file.

Modified:
    geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java

Modified: geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
URL: http://svn.apache.org/viewvc/geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=410704&r1=410703&r2=410704&view=diff
==============================================================================
--- geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java (original)
+++ geronimo/branches/1.1/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java Wed May 31 17:14:47 2006
@@ -36,9 +36,12 @@
 import org.apache.geronimo.system.serverinfo.ServerInfo;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
+import org.xml.sax.ErrorHandler;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
 
+import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.transform.TransformerFactory;
@@ -349,6 +352,7 @@
         }
         FileInputStream fis = new FileInputStream(attributeFile);
         InputSource in = new InputSource(fis);
+        in.setSystemId(attributeFile.toString());
         DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
         try {
             dFactory.setValidating(true);
@@ -357,7 +361,36 @@
                                  "http://www.w3.org/2001/XMLSchema");
             dFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",
                                  LocalAttributeManager.class.getResourceAsStream("/META-INF/schema/local-attributes-1.1.xsd"));
-            Document doc = dFactory.newDocumentBuilder().parse(in);
+            
+            DocumentBuilder builder = dFactory.newDocumentBuilder();
+            builder.setErrorHandler(new ErrorHandler() {
+                public void error(SAXParseException exception) {
+                    log.error("Unable to read saved manageable attributes. " +
+                        "SAX parse error: " + exception.getMessage() +
+                        " at line " + exception.getLineNumber() + 
+                        ", column " + exception.getColumnNumber() +
+                        " in entity " + exception.getSystemId());
+                    // TODO throw an exception here?
+                }
+
+                public void fatalError(SAXParseException exception) {
+                    log.error("Unable to read saved manageable attributes. " +
+                            "Fatal SAX parse error: " + exception.getMessage() +
+                            " at line " + exception.getLineNumber() + 
+                            ", column " + exception.getColumnNumber() +
+                            " in entity " + exception.getSystemId());
+                    // TODO throw an exception here?                    
+                }
+
+                public void warning(SAXParseException exception) {
+                    log.error("SAX parse warning whilst reading saved manageable attributes: " +
+                            exception.getMessage() +
+                            " at line " + exception.getLineNumber() + 
+                            ", column " + exception.getColumnNumber() +
+                            " in entity " + exception.getSystemId());
+                }
+            });            
+            Document doc = builder.parse(in);
             Element root = doc.getDocumentElement();
             serverOverride = new ServerOverride(root);
         } catch (SAXException e) {