[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Null Pointer when trying to use my persistent class



Hello:

I am getting a Null Pointer exception when I try to add a 
String object to a database class of mine.  Ozone is
apparently creating my database and the persistent object
fine.  It just dies when I try to manipulate the object.

Here is the output I am getting:
org.ozoneDB.OzoneInternalExc: java.lang.NullPointerException

	at org.ozoneDB.ExternalDatabase.sendCommand(ExternalDatabase.java:324)

	at org.ozoneDB.ExternalDatabase.sendCommand(ExternalDatabase.java:296)

	at org.ozoneDB.ExternalDatabase.createObject(ExternalDatabase.java:413)

	at org.ozoneDB.ExternalDatabase.createObject(ExternalDatabase.java:407)

	at OzoneTest.<init>(OzoneTest.java:39)

	at OzoneTest.main(OzoneTest.java:50)

Exception in thread "main" 

Here is the code for my main class (OzoneTest.java):
import java.io.*;
import org.ozoneDB.*;
import persistent.*;

public class OzoneTest {
  public static final String DB_DIR = "/Java/OzoneTest/Database";

  public OzoneTest() throws Exception {
    System.out.println(getClass().getName()+" starting.");

    // Create a local database instance
    LocalDatabase db = new LocalDatabase();

    // Try to open the database
    try {
      System.out.println( "Opening database" );
      db.open(DB_DIR);
    } catch(Exception e ) {
      // No database found, create one.
      System.out.println( "No database found, creating one." );
      db.create(DB_DIR);

      // Try to open the database
      db.open(DB_DIR);
    }

    // Create a person info object
    PersonInfo2 personInfo = (PersonInfo2)
db.createObject(PersonInfo2Impl.class.getName(),
        OzoneInterface.Public, "PersonInfo2");

    personInfo.addToNames("ZZZZ");
    personInfo.addToNames("AAA");
    personInfo.addToNames("JJHS");

    System.out.println(getClass().getName()+" finished.");
  }

  public static void main(String[] args) throws Exception {
    OzoneTest ozoneTest = new OzoneTest();
  }
}

Here is the code for my persistent class:

Here is the Interface (persistent/PersonInfo2.java):
package persistent;

import java.util.*;
import org.ozoneDB.*;

public interface PersonInfo2 extends OzoneRemote {
    public void setName( String name );
    public String getName();
    public void addToNames(String name);
    public Vector getNames();
}

Here is the implementation (persistent/PersonInfo2Impl.java):
package persistent;

import java.util.*;
import org.ozoneDB.*;

public class PersonInfo2Impl extends OzoneObject implements PersonInfo2
{
  private String name;
  private Vector names;

  public void setName(String name) {
    this.name = name;
  }

  public String getName() {
    return name;
  }

  public String toString() {
    return "PersonInfo for "+getName();
  }

  public void addToNames(String name) {
    if( names == null )
      names = new Vector();
    names.add(name);
  }

  public Vector getNames() {
    return names;
  }
}

Here is what I used to generate the proxy:
opp -ks -p"(set*|addTo*|removeFrom*)" -opersistent
persistent.PersonInfo2Impl

The PersonInfo2Impl_Proxy looks OK and it compiled just fine.

Any ideas??

Thanks,
	Neil.

--
Neil Aggarwal, President & CEO
JAMM Consulting, Inc. -- (972) 612-6056, http://www.JAMMConsulting.com
Custom Programming in Java, C++, HTML, perl