Muse 2 breaks on WLS with BEA StAX parser
-----------------------------------------
Key: MUSE-140
URL: http://issues.apache.org/jira/browse/MUSE-140
Project: Muse
Issue Type: Bug
Components: Deployment - Axis2
Affects Versions: 2.0.0
Environment: WLS 9.2
Reporter: James Shiell
Assigned To: Dan Jemiolo
Priority: Critical
When WLS 9.2 is used and the BEA StAX parser (as opposed to Woodstox) is being
used the AxisEnvironment class fails in the convertToDOM(OMElement) method.
This appears to be due to a WLS bug, where the serialised XML ommits namespace
declarations.
Given that it is not always possible to structure the classpath to use Woodstox
I have included a potential fix that does not rely on serialisation, instead
converting objects directly. This is compatible with both implementations and
hopefully slightly faster as well.
AxisEnvironment.java:
/**
* Convert Axiom to DOM. Muse uses the DOM API in the JDK, Axis2 uses
* the Axiom API, which is similar but... different.
*
* @param axiom the OM element.
* @return the converted element.
*/
public static Element convertToDOM(final OMElement axiom)
{
try
{
final DocumentBuilder domBuilder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
final Document doc = domBuilder.newDocument();
return convertToDom(axiom, doc);
}
catch (Throwable error)
{
throw new RuntimeException(error.getMessage(), error);
}
}
/**
* Convert an OM element into a DOM element.
*
* @param element the OM element.
* @param doc the DOM document to which DOM elements should belong.
* @return the DOM representation of the OM element.
*/
private static Element convertToDom(final OMElement element, final Document
doc)
{
final Element domElement =
doc.createElementNS(element.getNamespace().getNamespaceURI(),
element.getLocalName());
domElement.setTextContent(element.getText());
for (Iterator i = element.getAllAttributes(); i.hasNext();)
{
final OMAttribute attr = (OMAttribute) i.next();
domElement.setAttributeNS(attr.getNamespace().getNamespaceURI(),
attr.getLocalName(),
attr.getAttributeValue());
}
for (Iterator i = element.getChildElements(); i. hasNext();)
{
final Element child = convertToDom((OMElement) i.next(), doc);
domElement.appendChild(child);
}
return domElement;
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]