Reputation: 97
My project working fine with tomcat server and now I am trying to run project on WebSphere Liberty Profile(WLP) but its giving me below error for stax implementation
javax.xml.stream.XMLStreamException: The namespace URI "http://www.example.com/ns1" has not bound to a prefix.
at com.ibm.xml.xlxp.api.stax.msg.StAXMessageProvider.throwXMLStreamException(StAXMessageProvider.java:59)
at com.ibm.xml.xlxp.api.stax.XMLStreamWriterBase.writeAttribute(XMLStreamWriterBase.java:464)
at com.ibm.xml.xlxp.api.stax.XMLOutputFactoryImpl$XMLStreamWriterProxy.writeAttribute(XMLOutputFactoryImpl.java:157)
at org.apache.olingo.odata2.core.ep.producer.XmlMetadataProducer.writeAnnotationAttributes(XmlMetadataProducer.java:599)
at org.apache.olingo.odata2.core.ep.producer.XmlMetadataProducer.writeMetadata(XmlMetadataProducer.java:134)
i have set the classloader policy to parent-last in WLP. how to implement stax in IBM jre
Upvotes: 1
Views: 3107
Reputation: 97
Issue is resolved,thanks for your reply. Here is solution:I have added stax2-api and woodstox-core-asl jar into my project and set below property in my project system.properties
javax.xml.stream.XMLOutputFactory=com.ctc.wstx.stax.WstxOutputFactory
javax.xml.stream.XMLInputFactory=com.ctc.wstx.stax.WstxInputFactory
Upvotes: 1
Reputation: 1495
The IBM JRE does include STAX, it is required as part of Java SE.
The Javadoc for writeAttribute suggests that this exception is expected if you're writing an attribute with a namespace that you haven't yet bound to a prefix. Without more information about the document you're intending to write, I can't confirm whether this is the case.
If that is the case, you either need to fix the document you're writing so that it does set a prefix for the namespace before you use the namespace, or set the javax.xml.stream.isRepairingNamespaces
property on your output factory to true
before creating your XMLStreamWriter.
Following the example in the Javadoc:
xmlOutputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, new Boolean(true));
I don't know why this would work on tomcat but not liberty. More information on IBM's STAX implementation is available in the Knowledge Center.
Upvotes: 2