Thanks all for your input.
Here's my completed method, using Reflection so I can compile against other xmldb databases..
I'm getting a strange exception trace in Xindice 1.0, pasted below - I'd appreciate any ideas on why I'm getting this...



/**
* Xindice only method for adding indexes to a Collection.
* Pattern uses the following format :
* Pattern Description
* =========== ====================================================
* elem The value of the named element
* [EMAIL PROTECTED] The value of the attribute for the named element
* * The value for all elements
* [EMAIL PROTECTED] The value of the named attribute for all elements
* [EMAIL PROTECTED] The value of all attributes for the named element
* [EMAIL PROTECTED] The value of all attributes for all elements
*/
public void addIndex(Collection collection, String name, String pattern)
throws XMLDBException,
javax.xml.parsers.ParserConfigurationException {
Service collectionManager; // should be of type org.apache.xindice.client.xmldb.services.CollectionManager
collectionManager = collection.getService("CollectionManager", "1.0");
logger.info("Creating indexer");
try {
DocumentBuilder documentBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
org.w3c.dom.Document document = documentBuilder.newDocument();
org.w3c.dom.Element element = document.createElement("index");
document.appendChild(element);
element.setAttribute("class","org.apache.xindice.core.indexer.ValueIndexer");
element.setAttribute("name",name);
element.setAttribute("pattern",pattern);
//element.setAttribute("type",""); // optional
//element.setAttribute("pagesize",""); // optional
//element.setAttribute("maxkeysize","");// optional
Method createIndexerMethod = collectionManager.getClass().getDeclaredMethod("createIndexer",
new Class[]{org.w3c.dom.Document.class});
Object args[] = new Object[]{document};
createIndexerMethod.invoke(collectionManager,args);
}
catch (Throwable t) {
t.printStackTrace();
}
}



Here's my exception trace in the Xindince server, called with parameters name="ArbitraryName" and pattern="*" :


java.lang.NullPointerException
at org.apache.xindice.core.filer.BTree.findValue(BTree.java:213)
at org.apache.xindice.core.filer.BTree.findBTreeRoot(BTree.java:292)
at org.apache.xindice.core.indexer.ValueIndexer.add(ValueIndexer.java:345)
at org.apache.xindice.core.indexer.IndexManager$SAXHandler.processEntry(IndexManager.java:500)
at org.apache.xindice.core.indexer.IndexManager$SAXHandler.endElement(IndexManager.java:538)
at org.apache.xindice.xml.sax.SAXEventGenerator.processContainer(SAXEventGenerator.java:330)
at org.apache.xindice.xml.sax.SAXEventGenerator.processContainer(SAXEventGenerator.java:269)
at org.apache.xindice.xml.sax.SAXEventGenerator.processContainer(SAXEventGenerator.java:269)
at org.apache.xindice.xml.sax.SAXEventGenerator.processContainer(SAXEventGenerator.java:269)
at org.apache.xindice.xml.sax.SAXEventGenerator.start(SAXEventGenerator.java:342)
at org.apache.xindice.core.indexer.IndexManager$SAXHandler.<init>(IndexManager.java:462)
at org.apache.xindice.core.indexer.IndexManager$SAXHandler.<init>(IndexManager.java:478)
at org.apache.xindice.core.indexer.IndexManager.addDocument(IndexManager.java:392)
at org.apache.xindice.core.Collection.putDocument(Collection.java:627)
at org.apache.xindice.core.Collection.insertDocument(Collection.java:659)
at org.apache.xindice.client.corba.CollectionServant.insertDocument(CollectionServant.java:317)
at org.apache.xindice.client.corba.db.CollectionPOA._invoke(CollectionPOA.java:181)
at org.openorb.adapter.poa.POA.dispatch(POA.java:975)
at org.openorb.net.AbstractServerRequest.dispatch(AbstractServerRequest.java:750)
at org.openorb.net.ServerManagerImpl.serve_request(ServerManagerImpl.java:1467)
at org.openorb.net.ServerManagerImpl.thread_pool_main(ServerManagerImpl.java:1410)
at org.openorb.net.ServerManagerImpl.access$200(ServerManagerImpl.java:77)
at org.openorb.net.ServerManagerImpl$PoolThread.run(ServerManagerImpl.java:1557)
DEBUG> Index Creation: batchIndex
DEBUG> Index Complete: batchIndex
DEBUG> Populated Indexes: 187ms



Reply via email to