Hello everyone,

I am writing a simple Java application to learn the ins and outs of
Xindice.  

A method in the Java-app I have written which performs XPath queries is
occasionally causing the Xindice server to throw a Null Pointer exception.

The program compiles with out any warnings or errors, and runs fine, 90%
of the time.  One in (roughly) every 10 executions, the null pointer
exception is thrown (by the xindice server, not by my app) with the
following stack trace.

---------------------------Stack Trace------------------------------------

java.lang.NullPointerException
  at org.apache.xindice.core.DocumentCache$CacheKey.equals(Unknown Source)
  at java.util.WeakHashMap.eq(WeakHashMap.java:256)
  at java.util.WeakHashMap.get(WeakHashMap.java:348)
  at org.apache.xindice.core.DocumentCache.getDocument(Unknown Source)
  at org.apache.xindice.core.Collection.getDocument(Unknown Source)
  at 
org.apache.xindice.core.query.XPathQueryResolver$ResultSet.prepareNextNode(Unknown
Source)
  at
org.apache.xindice.core.query.XPathQueryResolver$ResultSet.getNextNode(Unknown
Source)
  at
org.apache.xindice.client.corba.CollectionServant.queryWrapper(Unknown
Source)
  at
org.apache.xindice.client.corba.CollectionServant.queryCollection(Unknown
Source)
  at
org.apache.xindice.client.corba.db.CollectionPOA._invoke(Unknown Source)
  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)

-----------------------------------------------------------------------------------




The Xindice command-line commands work fine.  I have used:

 xindice rd -c /db/bbs -n eg_submission
 xindice ld -c /db/bbs 
 xindice dd -c /db/bbs -n eg_submission

etc. without difficulty.

I have also tried deleting the bbs collection, and creating a fresh
collection.

I have tried running the application and the server on the following
machines.  On both, the server occasionally (roughly 1 in every 10
executions) throws the null-pointer-exception.

SunOS 5.8 Generic_108528-12 sun4u sparc SUNW,Ultra-1
SunOS 5.8 Generic_108528-08 sun4u sparc SUNW,Sun-Blade-1000

Here is the method which is performing the XPath query:





-------------------------XPath Query Method-----------------------------


  public static String xPathQuery(String xpath_query) {
    private static final String _collection_name = new
       String("xmldb:xindice:///db/bbs");
  private static final String _driver_name = new
       String("org.apache.xindice.client.xmldb.DatabaseImpl");   

    Collection col = null;
    String returnString = new String();
    try{  
      String driver = _driver_name;
      Class c = Class.forName(driver);
      
      Database database = (Database) c.newInstance();
      DatabaseManager.registerDatabase(database);
      
      col = DatabaseManager.getCollection(_collection_name);
 

      XPathQueryService service =
(XPathQueryService) col.getService("XPathQueryService","1.0");
      
      //get the results of the query
      ResourceSet resultSet = service.query(xpath_query);  
      
      //iterate through the results, getting the content and adding it to
      //the returnString
      System.out.println("\n\n\n"); //only for testing
      ResourceIterator results = resultSet.getIterator();
      while (results.hasMoreResources()) {
        Resource res = results.nextResource();
        returnString=returnString+res.getContent();
        //      returnString=returnString+"\n\n";//only for testing
      }
        System.out.println(returnString); //only for testing
        
        if(col != null) col.close();
    }
    catch (XMLDBException e) {
      System.err.println("XML:DB Exception occured " + e.errorCode);
      
    }
    catch (Exception e) {
      System.err.println("Other type of Exception occured");
      e.printStackTrace();
    }

    return(returnString);
  }

-----------------------------------------------------------------------


Does anyone have any suggestions?  Has anyone had a similar problem? Short
of trying to grok the Xindice-code, I'm out of ideas.

Thanks very much for your time -- and if you want any more information,
please don't hesitate to contact me.  I'll let you know if I get anywhere
with it.


Cheers,

Matthew Egbert

Reply via email to