Caused by: javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryB

1,126 views
Skip to first unread message

Kevin Mayfield

unread,
Sep 15, 2015, 7:23:47 AM9/15/15
to HAPI FHIR
Hi,

I've created a simple processor in Apache Camel to wrap files as a Binary resource. It works fine if I convert to JSON but the XML version fails 


Binary binaryDoc = new Binary();
// should really make this a little more flexible and get the correct mime type.
binaryDoc.setContentType("application/rtf");
binaryDoc.setContent(payload);
exchange.getIn().setHeader(Exchange.CONTENT_TYPE,"application/xml+fhir");
exchange.getIn().setHeader(Exchange.HTTP_QUERY, "_id="+exchange.getIn().getHeader(Exchange.FILE_NAME, String.class)); //+exchange.getIn().
exchange.getIn().setBody(ctx.newXmlParser().encodeResourceToString(binaryDoc));

Kevin Mayfield

unread,
Sep 15, 2015, 7:28:29 AM9/15/15
to HAPI FHIR
                final FhirContext ctx = FhirContext.forDstu2();
byte[] payload = exchange.getIn().getBody(byte[].class);
Binary binaryDoc = new Binary();
binaryDoc.setContentType("application/rtf");
binaryDoc.setContent(payload);
exchange.getIn().setHeader(Exchange.CONTENT_TYPE,"application/xml+fhir");
exchange.getIn().setHeader(Exchange.HTTP_QUERY, "_id="+exchange.getIn().getHeader(Exchange.FILE_NAME, String.class)); //+exchange.getIn().
exchange.getIn().setBody(ctx.newXmlParser().encodeResourceToString(binaryDoc));
Butter fingers caused the first entry to get posted. 

Changing the last line to exchange.getIn().setBody(ctx.newJsonParser().encodeResourceToString(binaryDoc)) works fine. When using XML (need to use XML due to limitations down the line) I get 
the following in the stack. Believe something similar has been found in the android implementation.

Caused by: javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.XMLOutputFactoryBase not found       
       at javax.xml.stream.FactoryFinder.newInstance(FactoryFinder.java:72)                                             
       at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:176)                                                   
       at javax.xml.stream.FactoryFinder.find(FactoryFinder.java:92)                                                    
       at javax.xml.stream.XMLOutputFactory.newInstance(XMLOutputFactory.java:98)                                       
       at ca.uhn.fhir.util.XmlUtil.getOrCreateOutputFactory(XmlUtil.java:1579)                                          
       at ca.uhn.fhir.util.XmlUtil.createXmlStreamWriter(XmlUtil.java:1536)                                             
       at ca.uhn.fhir.parser.XmlParser.createXmlWriter(XmlParser.java:146)                                              
       at ca.uhn.fhir.parser.XmlParser.doEncodeResourceToWriter(XmlParser.java:724)                                     
       at ca.uhn.fhir.parser.BaseParser.encodeResourceToWriter(BaseParser.java:264)                                     
       at ca.uhn.fhir.parser.BaseParser.encodeResourceToString(BaseParser.java:248)                                     
       at uk.nhs.chft.java.esb.fileToFHIRBinary.process(fileToFHIRBinary.java:57)                                       
       at org.apache.camel.processor.DelegateSyncProcessor.process(DelegateSyncProcessor.java:63)  

James Agnew

unread,
Sep 25, 2015, 3:33:44 PM9/25/15
to Kevin Mayfield, HAPI FHIR
Hi Kevin,

That error typically means that Java isn't finding any StAX implementation on the classpath. Do you have the woodstox JAR included in your project?

Cheers,
James

--
You received this message because you are subscribed to the Google Groups "HAPI FHIR" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hapi-fhir+...@googlegroups.com.
To post to this group, send email to hapi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hapi-fhir/a7918c3f-4317-487d-bf93-5b565bac68ee%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Kevin Mayfield

unread,
Sep 28, 2015, 5:23:59 AM9/28/15
to HAPI FHIR
Probably not, been having a 'bundle' of issues.

I've worked around the issue at the moment but will revisit.

Many thanks
Kevin
Reply all
Reply to author
Forward
0 new messages