Hi all!

I'm currently performing some test with Xindice 1.0rc1. The command line
tools and access via XindiceBrowser work fine, but trying to add some
documents using the API failes with the following exception

Exception in thread "main" java.lang.InstantiationError:
org.w3c.dom.DOMException
        at org.apache.xindice.xml.dom.NodeImpl.<clinit>(Unknown Source)
        at org.apache.xindice.xml.dom.DOMParser.startDocument(Unknown Source)
        at
org.apache.xerces.parsers.SAXParser.startDocument(SAXParser.java:1214)
        at
org.apache.xerces.validators.common.XMLValidator.callStartDocument(XMLValidator.java:1062)
        at
org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.dispatch(XMLDocumentScanner.java:685)
        at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
        at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081)
        at javax.xml.parsers.SAXParser.parse(SAXParser.java:374)
        at org.apache.xindice.xml.dom.DOMParser.parse(Unknown Source)
        at org.apache.xindice.xml.dom.DOMParser.parse(Unknown Source)
        at org.apache.xindice.xml.dom.DOMParser.parse(Unknown Source)
        at org.apache.xindice.xml.dom.DOMParser.toDocument(Unknown Source)
        at org.apache.xindice.xml.SymbolTableSymbols.<init>(Unknown Source)
        at org.apache.xindice.xml.SymbolTableSymbols.getInstance(Unknown
Source)
        at org.apache.xindice.client.corba.SymbolDeserializer.<clinit>(Unknown
Source)
        at org.apache.xindice.client.xmldb.CollectionImpl.<init>(Unknown
Source)
        at org.apache.xindice.client.xmldb.DatabaseImpl.getCollection(Unknown
Source)
        at
org.xmldb.api.DatabaseManager.getCollection(DatabaseManager.java:194)
        at
org.xmldb.api.DatabaseManager.getCollection(DatabaseManager.java:157)
        at ddom.util.XindiceLoader.main(XindiceLoader.java:28)

According to the JDK documentation such an exception is only thrown in
case you try to instatiate an interface (like DOMException in this
case), so I guess it must be an implementation bug. I have included the
piece of code that's causing the trouble, though it more or the less
follows the example from the developers guide.

  static final String COLLECTION = "xmldb:xindice:///db/dns";

  public static void main(String[] args) throws Exception {
    Collection col = null;
    try {

      //Connect to Xindice and get collection
      String driver = "org.apache.xindice.client.xmldb.DatabaseImpl";
      Class c = Class.forName(driver);
      Database database = (Database) c.newInstance();
      DatabaseManager.registerDatabase(database);
      col = DatabaseManager.getCollection(COLLECTION);

      ...

BTW I think there is a typo in the developers guide: In section 2.3
about adding documents it reads:

...
If you had your content already in a DOM tree you could also add the
document as a DOM. 

XMLResource document = (XMLResource) col.createResource(null); <- *
document.setContentAsDOM(doc); // doc is a DOM document
col.storeResource(document);
...

I think you need to specify the resource type at the line indicated by
<- * as done in the example above.

Thanks in advance,
Mathias

Reply via email to