I want to say I have ran into this before I would try increasing your
memory in your Tomcat. If that doesn't fix the problem let me know and I
can look into it deeper.

Add this

JAVA_OPTS="$JAVA_OPTS -Xmx512m"

To the the top of catalina.sh

Todd

[EMAIL PROTECTED] wrote:
> Hello,
> 
> I searched around these mail archives for posts about
> NullPointerExceptions, but I wasn't able to find a solution to my problem
> below.  Any advice on how to find a solution would be greatly appreciated.
> 
> Here is the message I receive from XMLDBException.GetMessage() call:
>  Failed to execute command 'GetResource' on server:
> http://localhost:8080/xindice/, message: java.lang.Exception:
> java.lang.NullPointerException
> 
> I'm using the following versions:
>  Xindice: 1.1b4
>  Tomcat:  5.0.25
>  JVM:     1.4.2_01-b06
>  OS:      Linux 2.4.18-14
> 
> Here is the sequence that causes this error:
>  1.  User updates web form and post to my Servlet
>  2.  My servlet does a GetResource() to pull the current version of the
> XML data.
>  3.  My servlet updates the XML data.
>  4.  My servlet does a createResource() and storeResource() to update the
> XML data back into Xindice.
>  5.  ... later user repeats steps 1 to 4.
> 
> Each time the user updates the form to Add/Update/Delete data.  About one
> in every ten cycles the NullPointException will be thrown when I perform
> the GetResource().  I tried having my code sleep for 2 seconds after the
> first GetResource() failed and then retry to call, but that only solves
> the problem once in awhile.
> 
> My XML data is usually somewhere in the 5 - 200 Kb range.  A posting said
> a storeResource should take about 3ms/KB, so I thought sleeping for 2
> seconds should have been enough delay for any of my files.
> 
> Thanks for the help,
> -Nate
> 
> Here is some code snippets.  I create a singleton that owns this class, so
> there is only one of these (currently).  Therefore EnableDatabase() is
> only executed once the first time that object is used.
> 
> 
> /*
>  * XindiceGateway.java
>  *
>  * Created on August 25, 2004, 9:31 PM
>  */
> 
> package org.test.gateways;
> 
> import java.util.Vector;
> import org.apache.log4j.Logger;
> import org.apache.xindice.client.xmldb.services.CollectionManager;
> import org.apache.xindice.xml.dom.DOMParser;
> import org.test.commands.DatabaseCommand;
> import org.w3c.dom.Node;
> 
> import org.xmldb.api.base.*;
> import org.xmldb.api.modules.*;
> import org.xmldb.api.*;
> 
> 
> /**
>  *
>  * @author  stoddarn
>  */
> public class XindiceGateway
> {
>   // Log4j Logger
>   static Logger m_logger = Logger.getLogger(XindiceGateway.class);
> 
>   // Static mutex on the database
>   static String m_databaseMutex = new String ("mutex");
> 
>   private boolean m_databaseRegistered = false;
> 
>   // Static XINDICE data
>   private static String XINDICE_DB_DRIVER = new
> String("org.apache.xindice.client.xmldb.DatabaseImpl");
> 
>   // The root to the database
>   private static String XINDICE_DB_ROOT = new
> String("xmldb:xindice://localhost:8080/db/");   // LINUX Penguin
> 
>   // Xindice API version
>   private static String XINDICE_API_VERSION = new String ("1.0");
> 
>   // Xindice file setup
>   private static String XINDICE_COMPRESSION_ENABLED = new String ("true");
>   private static String XINDICE_FILTER_CLASS = new
> String("org.apache.xindice.core.filer.BTreeFiler");
> 
> 
> /** Make sure the database is registered */
> protected void EnableDatabase ()
>        throws ClassNotFoundException, InstantiationException,
> IllegalAccessException,
>                XMLDBException
> {
>   // If the database isn't already registered
>   if (! m_databaseRegistered)
>   {
>     m_databaseRegistered = true;
> 
>     m_logger.info("Enabling Xindice Database");
> 
>     Class c = Class.forName(XINDICE_DB_DRIVER);
> 
>     Database database = (Database) c.newInstance();
>     DatabaseManager.registerDatabase(database);
> 
>     // Update the CodeReview paths
>     boolean baseCollectionFound = false;
>     boolean projectListingsCollectionFound = false;
>     boolean projectListingsFileFound = false;
>     boolean projectsCollectionFound = false;
> 
>     // Check for "test"
>     String [] baseCollection = ListCollections("");
>     // Loop to see if there is a match
>     for (int bcItr = 0; !baseCollectionFound && bcItr <
> baseCollection.length; bcItr++)
>     {
> 
>       if (baseCollection[bcItr].equals("test"))
>       {
>         baseCollectionFound = true;
>       }
>     }
>     // If the baseCollection is missing add it
>     if (!baseCollectionFound)
>     {
>       m_logger.info("Create codereview collection required");
>       CreateCollection("", "test");
>     }
> 
>     // Check for "projectlistings" and "projects"
>     String [] testCollection = ListCollections("test");
>     // Loop to see if there is a match for project listings and projects
>     for (int crItr = 0; (!projectListingsCollectionFound ||
> !projectsCollectionFound) && crItr < testCollection.length; crItr++)
>     {
>       if (testCollection[crItr].equals("projectlistings"))
>       {
>         projectListingsCollectionFound = true;
>       }
>       else if (testCollection[crItr].equals("projects"))
>       {
>         projectsCollectionFound = true;
>       }
>     }
>     // If the baseCollection is missing add it
>     if (!projectListingsCollectionFound)
>     {
>       m_logger.info("Create projectlistings collection required");
>       CreateCollection("test", "projectlistings");
>     }
> 
>     // If the baseCollection is missing add it
>     if (!projectsCollectionFound)
>     {
>       m_logger.info("Create projects collection required");
>       CreateCollection("test", "projects");
>     }
>   }
> }
> 
> 
> /** Add documents to a collection */
> public void AddDocument(String collectionName, String documentName, String
> documentXML)
> {
>   Collection col = null;
> 
>   String[] documents = null;
>   synchronized (m_databaseMutex)
>   {
>     try {
>       EnableDatabase();
> 
>       // Get the collection
>       col = DatabaseManager.getCollection(XINDICE_DB_ROOT + collectionName);
> 
>       XMLResource document = (XMLResource)
> col.createResource(documentName, "XMLResource");
>       document.setContent(documentXML);
>       col.storeResource(document);
>     }
>     catch (XMLDBException e) {
>       m_logger.error("AddDocument: XML:DB Exception occured: " +
> e.getMessage());
>     }
>     catch (Exception e) {
>       m_logger.error("AddDocument: Other Exception occured");
>     }
>     finally
>     {
>       // If the colletion was created, then make sure we close it
>       if (col != null)
>       {
>         try
>         {
>           // Close the collection
>           col.close();
>         }
>         catch (Exception e)
>         {
>           // Catch any issues with closing the exception.
>           m_logger.error("Unable to close collection.  " + e.getMessage());
>         }
>       }
>     }
>   }
> }
> 
> 
> /** Read a document */
> public String ReadDocument(String collectionName, String documentName)
> {
>   Collection col = null;
>   String returnString = null;
> 
>   synchronized (m_databaseMutex)
>   {
>     try {
>       EnableDatabase();
> 
>       col = DatabaseManager.getCollection(XINDICE_DB_ROOT + collectionName);
> 
>       XMLResource document = (XMLResource) col.getResource(documentName);
> 
>       returnString = (String)document.getContent();
>     }
>     catch (XMLDBException e) {
>       m_logger.error("ReadDocument (" + collectionName + "/" +
> documentName + "):  " + e.getMessage());
>     }
>     catch (Exception e) {
>       m_logger.error("ReadDocument (" + collectionName + "/" +
> documentName + "):  " + e.getMessage());
>     }
>     finally
>     {
>       // If the colletion was created, then make sure we close it
>       if (col != null)
>       {
>         try
>         {
>           // Close the collection
>           col.close();
>         }
>         catch (Exception e)
>         {
>           // Catch any issues with closing the exception.
>           m_logger.error("Unable to close collection.  " + e.getMessage());
>         }
>       }
>     }
>   }
> 
>    return (returnString);
>  }
> 
> 
> 
>   /** Creates a new instance of XindiceGateway */
>   public XindiceGateway()
>   {
>   }
> 
> }
> 

Reply via email to