LocalDatabase vs. RemoteDatabase

"Christian Merenda" <[email protected]>
Newsgroups gmane.comp.java.ozone.user
Message-ID <000501c43f22$3eafe7d0$0a1414ac@pcchristian>
Hello,
 
I´ve a weird problem and would be very pleased, if you could help me!
:-)
 
My software is quite complex, so I cannot explain every detail of the
solution. However it´s not necessary, because the whole thing works
fine, whenever I use a RemoteDatabase. This is my ozone initialization
code.
 
public class OzoneDB
{
    public static ExternalDatabase ozoneDB;
 
    public OzoneDB()
    {
       try
       {
         ozoneDB = ExternalDatabase.openDatabase(
"ozonedb:remote://localhost:3333" );
         ozoneDB.reloadClasses();
       }
       catch(Exception ex)
       {
         ex.printStackTrace();
       }
    }
}
 
Somewhat later I create an ozone object like this...
 
NationalizedStringDataOzoneRemote dataOzoneRemote =
(NationalizedStringDataOzoneRemote)
(OzoneDB.ozoneDB.createObject(NationalizedStringData.class.getName(), 0,
data.getId().toString()));
 
... and I use it to store and retrieve some information.
 
Now I want to switch to a local database. I do nothing except of
changing the ozone initialization code. I kept the type of the “ozoneDB”
variable as ExternalDatabase, in order to avoid an even more strange
failure. In that case object creation does not work any more and it
says: “java.lang.NoSuchFieldError: ozoneDB”. (?????) If I keep the
“ExternalDatabase” type, the system can create the object, store
information and retrieve some information. But the call to ...
 
if(dataOzoneRemote.getOwner() != null)
 
triggers the following exception:
 
WARN   [AWT-EventQueue-0] Transaction - ta[id=161,blocker=null]:
uncaught exception: (java.lang.RuntimeException: Object is not (yet)
associated to a database container.)
java.lang.RuntimeException: Object is not (yet) associated to a database
container.
            at org.ozoneDB.OzoneObject.container(OzoneObject.java:51)
            at
org.ozoneDB.core.ResultConverter.substituteOzoneCompatibles(ResultConver
ter.java:87)
            at
org.ozoneDB.core.DbRemote.DbInvoke.perform(DbInvoke.java:68)
            at
org.ozoneDB.core.Transaction.performCommand(Transaction.java:416)
            at
org.ozoneDB.core.TransactionManager.performCommand(TransactionManager.ja
va:403)
            at
org.ozoneDB.core.TransactionManager.completeTransaction(TransactionManag
er.java:369)
            at
org.ozoneDB.core.TransactionManager.handleCommand(TransactionManager.jav
a:283)
            at
org.ozoneDB.core.DbRemote.DbLocalClient.send(DbLocalClient.java:63)
            at
org.ozoneDB.ExternalDatabase.sendCommand(ExternalDatabase.java:517)
            at
org.ozoneDB.ExternalDatabase.sendCommand(ExternalDatabase.java:490)
            at
org.ozoneDB.ExternalDatabase.invoke(ExternalDatabase.java:782)
            at
com.gg.interfaces.NationalizedStringData_Proxy.getOwner(NationalizedStri
ngData_Proxy.java:674)
 
In fact the “owner” is null, because it´s not set before. Nevertheless
it makes no sense for me to search the fault in my code, because the
RemoteDatabase solution works fine!!! The following code snippet
represents the only one change.
 
public class OzoneDB
{
    public static ExternalDatabase ozoneDB;
 
    public OzoneDB()
    {
       try
       {
         String ozoneDir = "C:\\Program Files\\easyManager\\data";
         ozoneDB = new LocalDatabase();
 
         if(!((LocalDatabase)ozoneDB).exists(ozoneDir))
           ((LocalDatabase)ozoneDB).create(ozoneDir);
         ((LocalDatabase)ozoneDB).open(ozoneDir);
         ozoneDB.reloadClasses();
       }
       catch(Exception ex)
       {
         ex.printStackTrace();
       }
    }
}
 
So I´ve no idea what the problem could be! I hope you can help me. In
general, when is the exception “Object is not (yet) associated to a
database container.” raised?
 
Thanks in advance,
Christian Merenda
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.