logo       

Re: ConnectorFactory ClassCastException in getProcessor: msg#00001

text.xml.xforms.chiba.devel

Subject: Re: ConnectorFactory ClassCastException in getProcessor

hi martin,

while it might seem to be a safe change at first sight, it's pointing to a problem which originates elsewhere: why isn't your document element namespace aware ? how can this happen ? indeed it has to be a namespace aware element when it contains xforms markup, since you can't have xforms markup without namespaces at the time being.

therefore i won't apply the patch - you should investigate this issue further ;-)

regards,
uli.

Martin Tilma wrote:
Hello Joern,

Thanks for the reply!

Are there any reasons why to use:

ElementNSImpl elementNS = (ElementNSImpl) e.getOwnerDocument().getDocumentElement();

and not:

NodeImpl elementNS = (NodeImpl) e.getOwnerDocument().getDocumentElement();


(line 308 of org.chiba.xml.xforms.connector.ConnectorFactory)

The last one works for my application and doesn't affect the chiba examples, for so far as I can see. Is it possible to get it changed in the Chiba source code?

Greetings,

Martin

Joern Turner wrote:

Martin Tilma wrote:

Hello,

I have created a ChibaBean integration with Struts (not yet finished). And I use the "setXMLContainer(Node node)" method.

The node I'am providing is a XML data document which is transformed with XSL to a org.w3c.dom.Document (xhtml).

When you press the Submit button I get the following Exception:

Caused by: java.lang.ClassCastException: org.apache.xerces.dom.ElementImpl
at org.chiba.xml.xforms.connector.ConnectorFactory.getProcessor(ConnectorFactory.java:308)
...


the Exception is caused in the method:
org.chiba.xml.xforms.connector.ConnectorFactory.getProcessor(Element e)

The Element "e" at that time is a "org.apache.xerces.dom.ElementImpl" (I don't know why) so the cast to ElementNSImpl will fail.

My fix is to change the line:
ElementNSImpl elementNS = (ElementNSImpl) e.getOwnerDocument().getDocumentElement();

into:

NodeImpl elementNS = (NodeImpl) e.getOwnerDocument().getDocumentElement();

I have 2 questions:
1. Is this a valid fix ?
2. Why using the Xerces Implementation classes ?


We use Xerces implementation classes cause we're using the userobjects of Xerces DOM to associate Nodes with XForms functionality. So Chiba is not parser independent. This is a pragmatic move and cause we also need other functionality like DOM Events there are not much other options (parsers) to choose from. Sure, this could be considered not optimal but unless we don't make a major rewrite and effectively implement our own DOM Events implementation this situation would change in near future.

Joern


Kind regards,

Martin

---
protected ChibaBean getProcessor(Element e) {
// WAS: ElementNSImpl elementNS = (ElementNSImpl) e.getOwnerDocument().getDocumentElement();
NodeImpl elementNS = (NodeImpl) e.getOwnerDocument().getDocumentElement();

Object o = elementNS.getUserData();
if (o instanceof Container) {
return ((Container) o).getProcessor();
}
return null;
}

---




-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
Chiba-developer mailing list
Chiba-developer-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@xxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/chiba-developer




--
Ulrich Nicolas Lissé



-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise