"xmlns has been already bound" error from XMLStreamWriterImpl w/ valid XML
I have a web service deployed to Glassfish and whenever it returns a response that marshals into XML with one or more nested elements the container fails to write the response and issues the following message:
"javax.xml.stream.XMLStreamException: xmlns has been already bound to . Rebinding it to is an error"
Note that "" is an actual namespace that I have removed for security reasons.
The source of this error is com.sun.xml.stream.writers.XMLStreamWriterImpl.writeDefaultNamespace(XMLStreamWriterImpl.java:791)
I cannot share with you the actual XML but when I unmarshal my response object to XML it is of a form similar to below:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
If I modify the response to only contain the root element the response XML is wriiten without error, so I believe that this class is for some reason taking issue with the use of the default namespace. Is there some reason why the use of namespaces above is considered invalid by XMLStreamWriterImpl? I understand that it is prefereable to use a NS prefix rather than relying on the default NS behavior, but this is how JAXB marshals my XJC-generated object and I am not sure how to change this behavior.