DeferredElementNSImpl

I have a problem with my code. I send it with its related xml file in attachment.
I get the error:
java.lang.ClassCastException: org.apache.xerces.dom.DeferredElementNSImpl
at Database2.sample(Database2.java:85)
at Database2.main(Database2.java:134)
Exception in thread “main”

Thx
@nto
AccessListaMe.xml (719 Bytes)

Here is the code.

@nto
Database2.java (4.23 KB)

The reason for the ClassCastException is that the returned value from the following line:

Element accessList = (Element)xmlObject.getElement();

is a org.w3c.dom.Element and the Element accessList in this case is imported from org.jdom.* (line 8 in the source). The reason a org.w3c.dom.Element is being returned is because you have asked to use the TDOMObjectModel when creating the TXMLObjectAccessor.

So you either need to :
1) change org.jdom imports to org.w3c.dom imports;
2) or change the object model to TJDOMObjectModel.


Stuart Fyffe-Collins
Software AG (UK) Ltd.

I’m trying your first solution, but i have to change getChildren, in getElementByTagName and i have i insert Nodelist of java.util import, is it correct?

Ths
@

The first solution have to many changes to do. So i try the second changing

accessor = connection.newXMLObjectAccessor(
TAccessLocation.newInstance( collection ) ,
TDOMObjectModel.getInstance() );

in
accessor = connection.newXMLObjectAccessor(
TAccessLocation.newInstance( collection ) ,
TJDOMObjectModel.getInstance() );
with adding the following import
import com.softwareag.tamino.db.API.objectModel.jdom.*;

and it works!!!
Many Thanks Stuart!!!
@nto