Community
Participate
Working Groups
AJDT uses the WeavingURLClassLoader to enable load-time weaving in Eclipse. If the projects that the user is attempting to load-time weave refer to a 1.4 version of the JRE the following exception occurs: warning Register definition failed -- (SAXException) System property org.xml.sax.driver not specified System property org.xml.sax.driver not specified org.xml.sax.SAXException: System property org.xml.sax.driver not specified at org.xml.sax.helpers.XMLReaderFactory.createXMLReader(Unknown Source) at org.aspectj.weaver.loadtime.definition.DocumentParser.parse (DocumentParser.java:80) at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.registerDefinitions (ClassLoaderWeavingAdaptor.java:148) at org.aspectj.weaver.loadtime.ClassLoaderWeavingAdaptor.initialize (ClassLoaderWeavingAdaptor.java:109) at org.aspectj.weaver.loadtime.WeavingURLClassLoader.defineClass (WeavingURLClassLoader.java:106) at org.aspectj.weaver.ExtensibleURLClassLoader.defineClass (ExtensibleURLClassLoader.java:80) at org.aspectj.weaver.ExtensibleURLClassLoader.findClass (ExtensibleURLClassLoader.java:46) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Try -Dorg.xml.sax.parser=org.apache.xerces.parsers.SAXParser
Unfortunately the SAXParser class isn't there in the 1.4 library and I couldn't find a suitable replacement. I wondered whether it might be possible to change the use of the SAXParser to use a DocumentBuilder instead. E.g. to read an XML file into an org.w3c.dom.Document do the following: InputStream fileContents = ..... DocumentBuilder builder = DocumentBuilderFactory.newInstance ().newDocumentBuilder(); builder.setErrorHandler(new AOPXMLErrorHandler()); Document document = builder.parse(fileContents); AOPXMLErrorHandler might look like this: /** * Error handler class for AOP XML parsing exceptions */ private static class AOPXMLErrorHandler extends DefaultHandler { /** * Throws a more detailed exception when an error occurs parsing a file. * @param exception - the Exception input * @throws SAXException - more detained Exception * @see org.xml.sax.ErrorHandler#error (org.xml.sax.SAXParseException) */ public void error(SAXParseException exception) throws SAXException { throw new AOPXMLException( "A problem occurred parsing aop.xml file " // $NON-NLS-1$ + exception.getSystemId().substring( exception.getSystemId().indexOf ("file:///") + 8) //$NON-NLS-1$ + "[" //$NON-NLS-1$ + exception.getLineNumber() + "," //$NON-NLS-1$ + exception.getColumnNumber() + "]" //$NON-NLS-1$ + System.getProperty ("line.separator") //$NON-NLS-1$ + exception.getMessage().substring( exception.getMessage().indexOf (':') + 2)); } /** * Throws a more detailed exception when a warning occurs while * parsing a file * @param exception - inout * @throws SAXException - more detailed output * @see org.xml.sax.ErrorHandler#warning (org.xml.sax.SAXParseException) */ public void warning(SAXParseException exception) throws SAXException { error(exception); } /** * Throws a more detailed exception when a fatal error occurs while * parsing a file * @param exception - input * @throws SAXException - more detailed output * @see org.xml.sax.ErrorHandler#fatalError (org.xml.sax.SAXParseException) */ public void fatalError(SAXParseException exception) throws SAXException { error(exception); } } These snippets are taken from org.eclipse.ajdt.internal.launching.LTWUtils in the AJDT UI plug-in.
can' t we package Xerces from Apache website ? I am not sure about the DOM API you suggest but I think you 'll have the same issue ie using DOM will require a DOM implementation as well (and even more probably a SAX one as well as lower layer)
Andy to discuss with Sian.
Ok, had a discussion on this. I really don't want to get into shipping a copy of xerces.jar. The DocumentBuilder stuff Sian describes in her comment is in my 1.4 vm and my 1.5 vm. Alex, is there a real problem with using this seemingly common interface? (I'm not an XML parsing expert by any means...) I don't mind asking command line compiler users to have an XML parser around (although even that seems unfriendly if there is support in the base JDK) but we can't expect AJDT users to conjure one up. Eclipse used to ship xerces but decided to get out of that game in the 3.0 timeframe.
can someone try with XMLReader xmlReader = javax.xml.parsers.SAXParserFactory.newInstance().newSAXParser().getXMLReader(); // XMLReaderFactory.createXMLReader(); in DocumentParser:81 I don't want to use DOM (unless we want to have yet more memory for LTW)
I tried: XMLReader xmlReader = javax.xml.parsers.SAXParserFactory.newInstance().newSAXParser().getXMLReader(); and it works fine (as far as I can tell). Shall I change it Alex?
sure go ahead this looks like this one will use the bundled factory or something
change committed. will wait for Sian to confirm its ok with Eclipse 3.0 before closing.
Sian confirmed the fix is OK for Eclipse 3.0 users. Closing this bug.