I am passing a well formed xml document as a DOM document into a method
that is supposed to insert it into a dbxml database. But whenever i start
my program i get a java.lang.NullpointerExeption

I have found the line causing the trouble and it goes like this

XMLResource resource =
        (XMLResource) col.createResource(id, XMLResource.RESOURCE_TYPE);

Anyone who could tell me what's wrong??

The whole class/method goes like:

import org.xmldb.api.base.*;
import org.xmldb.api.modules.*;
import org.xmldb.api.*;
import org.w3c.dom.Document;
import java.io.*;

Public class AddDocument{

    public void add(Document doc) throws Exception{

        Collection col = null;
        try{

            String driver = "org.dbxml.client.xmldb.DatabaseImpl";
            Class c = Class.forName(driver);
            Database database = (Database) c.newInstance();
            DatabaseManager.getCollection("xmldb:dbxml:///db/REAP/Profiles");

            String id = "test";

            //this is the line where the exception is thrown:
            XMLResource document =
                  (XMLResource) col.createResource(id, 
XMLResource.RESOURCE_TYPE);

            document.setContentAsDom(doc); //doc is the received xml dom 
document
            col.storeResource(document);

        }

        catch (XMLDBExeption e){
            System.err.println("Error occured " + e.errorCode)
        }

        finally{
            if (col !=null){
                col.close;
            }
        }
    }
}

It would really help me if anyone of you knew what's wrong..

Thanks �yvind

�yvind Vestavik
�vre M�llenberggt 44b
7014 Trondheim
[EMAIL PROTECTED]
41422911


Reply via email to