Problem Problem generating schema when using MTOM with Websphere 7
Caused by: javax.xml.stream.XMLStreamException: The namespace URI "http://www.w3.org/2005/05/xmlmime" has not been bound to a prefix.
at
com.ibm.xml.xlxp2.api.stax.msg.StAXMessageProvider.throwXMLStreamException(StAXMessageProvider.java:62)
at
com.ibm.xml.xlxp2.api.stax.XMLStreamWriterBase.writeAttribute(XMLStreamWriterBase.java:471)
at
com.ibm.xml.xlxp2.api.stax.XMLOutputFactoryImpl$XMLStreamWriterProxy.writeAttribute(XMLOutputFactoryImpl.java:161)
at org.apache.cxf.staxutils.StaxUtils.writeElement(StaxUtils.java:637)
at org.apache.cxf.staxutils.StaxUtils.writeElement(StaxUtils.java:550)
at org.apache.cxf.staxutils.StaxUtils.writeNode(StaxUtils.java:667)
[... etc ...]
at
org.apache.cxf.transport.http.WSDLQueryHandler.writeResponse(WSDLQueryHandler.java:218)
... 38 more
Solution
Summary: The problem is the IBM Stax parser implementation. Use the Woodstox parser instead.
Details: Daniel Kulp from the Apache CXF team
suggests the solution of using the
Woodstox parser instead of IBM's stax parser.
But it took me
quite a bit of digging to figure out how to accomplish this
without any major code changes.
Here's how I made it work without any code changes:
- Grab a copy of woodstox-core-lgpl-4.0.7.jar and make sure it's in your application's classpath.
- Follow these instructions to add the following system variables to websphere:
-
name: javax.xml.parsers.DocumentBuilderFactory
value: org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
-
name: javax.xml.parsers.SAXParserFactory
value: org.apache.xerces.jaxp.SAXParserFactoryImpl
-
name: javax.xml.transform.TransformerFactory
value: org.apache.xalan.processor.TransformerFactoryImpl
-
name: javax.xml.stream.XMLInputFactory
value: com.ctc.wstx.stax.WstxInputFactory
-
name: javax.xml.stream.XMLOutputFactory
value: com.ctc.wstx.stax.WstxOutputFactory
-
name: javax.xml.stream.XMLEventFactory
value: com.ctc.wstx.stax.WstxEventFactory
- Restart Websphere
update
Alternatively, instead of setting this in WAS, you can add these to your web.xml config file:
<context-param>
<param-name>javax.xml.parsers.DocumentBuilderFactory</param-name>
<param-value>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>javax.xml.parsers.SAXParserFactory</param-name>
<param-value>org.apache.xerces.jaxp.SAXParserFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>javax.xml.transform.TransformerFactory</param-name>
<param-value>org.apache.xalan.processor.TransformerFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>org.apache.xalan.xsltc.trax.TransformerFactoryImpl</param-name>
<param-value>org.apache.xalan.processor.TransformerFactoryImpl</param-value>
</context-param>
<context-param>
<param-name>javax.xml.stream.XMLOutputFactory</param-name>
<param-value>com.ctc.wstx.stax.WstxOutputFactory</param-value>
</context-param>
<context-param>
<param-name>javax.xml.stream.XMLEventFactory</param-name>
<param-value>com.ctc.wstx.stax.WstxEventFactory</param-value>
</context-param>