tags:

views:

214

answers:

1

I'm using db4o 6.4.54 in OSGi environment as a model storage. Every time I restart OSGi framework, the database appears to be empty, although the file is there and not empty definitely.

I have the following configuration:

A core bundle, which depends on the standard db4o_osgi bundle provided by db4o. An UI bundle, which depends on the core plugin, from where it gets the model.

The core bundle creates in-memory server via openServer(String, 0) method and then create separate clients for each request/thread.

The problem is that, every time the db4o server is created, queries returns no result.

I tried to use the service, but it also didn't work.

The next step in my testing was to include the db4o directly into my bundle and it worked (the effect was that db4o classes are loaded by the same classloader as the model object, which I stored into the database). There is one post in the db4o forum [1], but it fails to explain why this problem exists and how it should be solved (correctly). I'll continue my investigations, but I wonder whether anyone else have tuckle this problem before me?

+1  A: 

Did you commit the changes and close the client connection up on shutting down the osgi bundle?

E.g.: sth like

ObjectContainer client;

public void start(BundleContext context) throws Exception {
   client = Db4oClientServer.openClient(...);
}    

public void stop(BundleContext context) throws Exception {
   if (!client.ext().isClosed())
      client.close();
}

Or look into my standalone Db4oServer which could recieve a message 'STOP' from a client to be stopped.

Karussell