ClassNotFoundExc
"Trond Hundstuen" <[email protected]>
| Newsgroups | gmane.comp.java.ozone.user |
|---|---|
| Message-ID | <[email protected]> |
Hello.
I'm trying to test one of the examples given in your documentation, however
it doesn't work.
The error I get is the following:
java.lang.RuntimeException: Caught during
createObject("test.CarImpl",0,my_first_car,"null"):
org.ozoneDB.ClassNotFoundExc: test.CarImpl
at org.ozoneDB.ExternalDatabase.createObject(ExternalDatabase.java:731)
at org.ozoneDB.AbstractDatabase.createObject(AbstractDatabase.java:24)
at test.MyApp.createCar(MyApp.java:35)
at test.MyApp.main(MyApp.java:22)
at java.lang.reflect.Method.invoke(Native Method)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:78)
Exception in thread "main" Process terminated with exit code 1
All I have done is to copy and paste the code in the example and put them in
package "test". I've tried without packaging them as well, but same error. I
use jdk1.3.1.
Here's the code:
package test;
import org.ozoneDB.OzoneRemote;
public interface Car extends OzoneRemote {
public void setName( String name ); /*update*/
public String name();
public void setYearOfConst( int year ); /*update*/
public int age();
}
package test;
import org.ozoneDB.OzoneObject;
import java.util.*;
import test.Car;
public class CarImpl extends OzoneObject implements Car {
/**
Set version of the serialized data to make it compatible with
new class versions.
*/
final static long serialVersionUID = 1L;
private String _name;
private int _yearOfConst;
public CarImpl() {
_name = new String( "" );
_yearOfConst = 0;
}
public String name() {
return _name;
}
public void setName( String name ) {
_name = name;
}
public void setYearOfConst( int year ) {
_yearOfConst = year;
}
public int age() {
Calendar cal = Calendar.getInstance();
return cal.get (Calendar.YEAR) - _yearOfConst;
}
}
package test;
import org.ozoneDB.*;
public class MyApp {
private static ExternalDatabase db;
public static void main( String[] args ) throws Exception {
if (args.length == 0) {
System.out.println( "usage: ojvm MyApp create|delete|print" );
System.exit( 1 );
}
// create and open a new database connection
db = ExternalDatabase.openDatabase(
"ozonedb:remote://localhost:3333" );
System.out.println( "Connected ..." );
db.reloadClasses();
if (args[0].equals( "create" )) {
createCar();
} else if (args[0].equals( "delete" )) {
deleteCar();
} else {
printCar();
}
db.close();
}
public static void createCar() throws Exception {
// create a new Car object with the name "my_first_car"
// the return value is Car_proxy, which implements the
Car-interface
Car car = (Car)(db.createObject( CarImpl.class.getName(), 0,
"my_first_car" ));
car.setName( "gottfried" );
car.setYearOfConst( 1957 );
}
public static void printCar() throws Exception {
Car car = (Car)(db.objectForName( "my_first_car" ));
if (car != null) {
System.out.println( "The car " + car.name() + " is "
+ car.age() + " years old." );
} else {
System.out.println( "Object my_first_car not found." );
}
}
public static void deleteCar() throws Exception {
Car car = (Car)(db.objectForName( "my_first_car" ));
if (car != null) {
db.deleteObject( car );
} else {
System.out.println( "Object my_first_car not found." );
}
}
}
I've tried searching around on the net, but still haven't found an answer to
this (Probably easy) error, so any help would be appreciated.
Best regards,
Trond Hundstuen.
_________________________________________________________________
MSN Hotmail http://www.hotmail.com Med markedets beste SPAM-filter. Gratis!
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click