Hi,

The idea was to put Implementation and Database
in session context using a ServletContext Event Listener Class
and after that to allow all users to get those object from session scope.

But it seams that Database is null for all threads except thread where db
was
opened, so errors occur every time I tried to start Transaction
(tx.begin())??

Is there any solution for this or I have to
open my db for every thread (user) again and again???


The following code has been used:

*** ServletContext Event Listener Class************
public void contextInitialized(ServletContextEvent event){
     Implementation odmg = OJB.getInstance();
     Database db = odmg.newDatabase();
     db.open("repository.xml", Database.OPEN_READ_WRITE);

     context.setAttribute(IConstants.OJB_SETTINGS, odmg);
     context.setAttribute(IConstants.OJB_DB, db);
}

*** ServletContext Event Listener Class END  ************

*** Client  Class************
public void blahBlah () {
     Implementation odmg =
        (Implementation) context.getAttribute(IConstants.OJB_SETTINGS);
     Database db =
        (Database) context.getAttribute(IConstants.OJB_DB);
        // tried also Database db = odmg.newDatabase(null);

     Transaction tx = odmg.newTransaction();
     tx.begin();
     // BANG ??????????????????

}

*** Client Class END  ************

Marino Tudor









--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to