List of usage examples for javax.xml.parsers FactoryConfigurationError getException
public Exception getException()
From source file:org.onehippo.repository.bootstrap.instructions.ContentResourceInstruction.java
InputStream getPartialContentInputStream(InputStream in, final String contextRelPath) throws IOException, RepositoryException { File file = File.createTempFile("bootstrap-", ".xml"); OutputStream out = null;/*w ww . j a v a 2s. c o m*/ try { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); factory.setFeature("http://xml.org/sax/features/namespace-prefixes", false); SAXParser parser = factory.newSAXParser(); out = new FileOutputStream(file); TransformerHandler handler = ((SAXTransformerFactory) SAXTransformerFactory.newInstance()) .newTransformerHandler(); Transformer transformer = handler.getTransformer(); transformer.setOutputProperty(OutputKeys.METHOD, "xml"); transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); handler.setResult(new StreamResult(out)); parser.parse(new InputSource(in), new DefaultContentHandler(new PartialSystemViewFilter(handler, contextRelPath))); return new TempFileInputStream(file); } catch (FactoryConfigurationError e) { throw new RepositoryException("SAX parser implementation not available", e); } catch (ParserConfigurationException e) { throw new RepositoryException("SAX parser configuration error", e); } catch (SAXException e) { Exception exception = e.getException(); if (exception instanceof RepositoryException) { throw (RepositoryException) exception; } else if (exception instanceof IOException) { throw (IOException) exception; } else { throw new InvalidSerializedDataException("Error parsing XML import", e); } } catch (TransformerConfigurationException e) { throw new RepositoryException("SAX transformation error", e); } finally { IOUtils.closeQuietly(out); } }
From source file:org.settings4j.config.DOMConfigurator.java
private void doConfigure(final ParseAction action) throws FactoryConfigurationError { DocumentBuilderFactory dbf = null; try {//from www .j ava 2s.c o m LOG.debug("System property is: {}", System.getProperty(DOCUMENT_BUILDER_FACTORY_KEY)); dbf = DocumentBuilderFactory.newInstance(); LOG.debug("Standard DocumentBuilderFactory search succeded."); LOG.debug("DocumentBuilderFactory is: {}", dbf.getClass().getName()); } catch (final FactoryConfigurationError fce) { final Exception e = fce.getException(); LOG.debug("Could not instantiate a DocumentBuilderFactory.", e); throw fce; } try { dbf.setValidating(true); final DocumentBuilder docBuilder = dbf.newDocumentBuilder(); docBuilder.setErrorHandler(new SAXErrorHandler()); docBuilder.setEntityResolver(new Settings4jEntityResolver()); final Document doc = action.parse(docBuilder); parse(doc.getDocumentElement()); } catch (final Exception e) { // I know this is miserable... LOG.error("Could not parse {}.", action.toString(), e); } }