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 06:56:25 UTC
svn commit: r410746 -
/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
Author: jsisson
Date: Wed May 31 21:56:25 2006
New Revision: 410746
URL: http://svn.apache.org/viewvc?rev=410746&view=rev
Log:
GERONIMO-2069 - Merge from 1.1 branch (rev 410704) - 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/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
Modified: geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java
URL: http://svn.apache.org/viewvc/geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java?rev=410746&r1=410745&r2=410746&view=diff
==============================================================================
--- geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java (original)
+++ geronimo/trunk/modules/system/src/java/org/apache/geronimo/system/configuration/LocalAttributeManager.java Wed May 31 21:56:25 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) {