use of javax.xml.stream.FactoryConfigurationError in project teiid by teiid.
the class PlanNode method toXml.
/**
* Converts this PlanNode to XML. See the JAXB bindings for the
* document form.
* @return an XML document of this PlanNode
*/
public String toXml() {
try {
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
StringWriter stringWriter = new StringWriter();
XMLStreamWriter writer = outputFactory.createXMLStreamWriter(stringWriter);
// $NON-NLS-1$ //$NON-NLS-2$
writer.writeStartDocument("UTF-8", "1.0");
writePlanNode(this, writer);
writer.writeEndDocument();
return stringWriter.toString();
} catch (FactoryConfigurationError e) {
throw new TeiidRuntimeException(JDBCPlugin.Event.TEIID20002, e);
} catch (XMLStreamException e) {
throw new TeiidRuntimeException(JDBCPlugin.Event.TEIID20003, e);
}
}
use of javax.xml.stream.FactoryConfigurationError in project uPortal by Jasig.
the class EventProviderImpl method createEvent.
@Override
public Event createEvent(QName qname, Serializable value) throws IllegalArgumentException {
if (this.isDeclaredAsPublishingEvent(qname)) {
if (value != null && !this.isValueInstanceOfDefinedClass(qname, value)) {
throw new IllegalArgumentException("Payload class (" + value.getClass().getCanonicalName() + ") does not have the right class, check your defined event types in portlet.xml.");
}
if (value == null) {
return new EventImpl(qname);
}
try {
final Thread currentThread = Thread.currentThread();
final ClassLoader cl = currentThread.getContextClassLoader();
final Writer out = new StringWriter();
final Class clazz = value.getClass();
try {
currentThread.setContextClassLoader(this.portletClassLoader);
final JAXBContext jc = JAXBContext.newInstance(clazz);
final Marshaller marshaller = jc.createMarshaller();
final JAXBElement<Serializable> element = new JAXBElement<Serializable>(qname, clazz, value);
marshaller.marshal(element, out);
} finally {
currentThread.setContextClassLoader(cl);
}
return new EventImpl(qname, out.toString());
} catch (JAXBException e) {
// maybe there is no valid jaxb binding
// TODO throw exception?
logger.error("Event handling failed", e);
} catch (FactoryConfigurationError e) {
// TODO throw exception?
logger.warn(e.getMessage(), e);
}
}
return null;
}
use of javax.xml.stream.FactoryConfigurationError in project mule by mulesoft.
the class DefaultXMLSecureFactories method createDocumentBuilderFactory.
public DocumentBuilderFactory createDocumentBuilderFactory() {
DocumentBuilderFactory factory;
if (System.getProperty(DOCUMENT_BUILDER_PROPERTY) == null) {
try {
factory = DocumentBuilderFactory.newInstance(DOCUMENT_BUILDER_FACTORY, DefaultXMLSecureFactories.class.getClassLoader());
} catch (FactoryConfigurationError e) {
logCreationWarning(DocumentBuilderFactory.class.getName(), DOCUMENT_BUILDER_FACTORY, e);
factory = DocumentBuilderFactory.newInstance();
}
} else {
factory = DocumentBuilderFactory.newInstance();
}
try {
factory.setFeature("http://xml.org/sax/features/external-general-entities", externalEntities);
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", externalEntities);
factory.setExpandEntityReferences(expandEntities);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", !expandEntities);
} catch (Exception e) {
logConfigurationWarning(DocumentBuilderFactory.class.getName(), factory.getClass().getName(), e);
}
return factory;
}
use of javax.xml.stream.FactoryConfigurationError in project mule by mulesoft.
the class DefaultXMLSecureFactories method createTransformerFactory.
public TransformerFactory createTransformerFactory() {
TransformerFactory factory;
if (System.getProperty(TRANSFORMER_PROPERTY) == null) {
try {
factory = TransformerFactory.newInstance(TRANSFORMER_FACTORY, DefaultXMLSecureFactories.class.getClassLoader());
} catch (FactoryConfigurationError e) {
logCreationWarning(TransformerFactory.class.getName(), TRANSFORMER_FACTORY, e);
factory = TransformerFactory.newInstance();
}
} else {
factory = TransformerFactory.newInstance();
}
configureTransformerFactory(factory);
return factory;
}
use of javax.xml.stream.FactoryConfigurationError in project galley by Commonjava.
the class PomPeek method parseCoordElements.
private void parseCoordElements() {
InputStream in = null;
XMLStreamReader xml = null;
try {
if (pom != null) {
in = new FileInputStream(pom);
} else if (transfer != null) {
in = transfer.openInputStream(false);
} else {
in = stream;
}
xml = XMLInputFactory.newFactory().createXMLStreamReader(in);
final Stack<String> path = new Stack<>();
while (xml.hasNext()) {
final int evt = xml.next();
switch(evt) {
case START_ELEMENT:
{
final String elem = xml.getLocalName();
if (captureValue(elem, path, xml)) {
// seems like xml.getElementText() traverses the END_ELEMENT event...
path.pop();
}
break;
}
case END_ELEMENT:
{
path.pop();
break;
}
default:
{
}
}
if (foundAll()) {
return;
}
}
} catch (final IOException | FactoryConfigurationError | XMLStreamException e) {
logger.warn("Failed to peek at POM coordinate for: " + pom + " Reason: " + e.getMessage() + "\nThis POM will NOT be available as an ancestor to other models during effective-model building.", e);
} finally {
if (xml != null) {
try {
xml.close();
} catch (final XMLStreamException e) {
logger.warn("Failed to close XMLStreamReader: " + e.getMessage(), e);
}
}
closeQuietly(in);
}
}
Aggregations