I have the following exception....
exception java.lang.ClassCastException:
org.apache.crimson.tree.XmlDocument
when I try make A class cast from
org.w3c.dom.Document to com.sun.tree.xml.XmlDocument
The code:
(...)
private DocumentBuilderFactory
m_documentBuilderFactory = DocumentBuilderFactory.newInstance();
/** */
private DocumentBuilder
m_documentBuilder;
(...)
try
{
m_documentBuilder =
m_documentBuilderFactory.newDocumentBuilder();
} catch
(Exception e) {
throw new
RuntimeException(e.getMessage());
}
(...)
Document returnDoc =
null;
Node tempNode =
msg.getContent();
tempNode =
FIPA.ACL.Util.getNode(tempNode, FIPAConstants.Apply);
if
(FIPAConstants.Action.equals(tempNode.getFirstChild().getNodeName()))
{
tempNode = FIPA.ACL.Util.getNode(tempNode,
FIPAConstants.Apply);
// checks whether it is really a forward
action ...
String messageType =
tempNode.getFirstChild().getFirstChild().getFirstChild().getNodeValue();
if
(messageType.indexOf(FIPAConstants.Forward) >= 0 )
{
tempNode = Util.getNode(tempNode, FIPAConstants.Message );
if
(tempNode == null) {
System.out.println("ACC: message content is null
!!");
}
returnDoc
= m_documentBuilder.newDocument();
try
{
Node copy =
tempNode.cloneNode(true);
com.sun.xml.tree.XmlDocument xmlD=(com.sun.xml.tree.XmlDocument)
returnDoc; ***********Localization of
ERROR
**************
xmlD.changeNodeOwner(copy);
returnDoc.appendChild(copy); //aha
} catch
(Exception e) {
System.out.print("ACC: caught exception
"+e.toString()+"\n");
e.printStackTrace() ;
}
Can you help me?
Thanks in advanced.
Joćo
Sarraipa