Thanks for your suggestions Armin. I found a place where
broker.close() was not being called and it was causing broker
leak.

Thanks again
Ashish


Armin Waibel wrote:
Hi,

you can use a shared helper class which provides access to the used Implementation instance and Database. No need to do

 > odmg = OJB.getInstance();
 >             db = odmg.newDatabase();
 >             db.open("default", Database.OPEN_READ_WRITE);

on each call.


If you get the PB instance within a running odmg-tx via broker = ((TransactionExt) tx).getBroker(); (recommended 1.0) or broker = ((HasBroker) tx).getBroker();

it's not allowed to close the used broker instance, OJB will do that on commit/abort of the odmg-tx. Seems your doing exactly this. So this shouldn't case the leak.


> Could you please advise here what all I am doing wrong and what is > causing the leak?

Don't know the reason.
Could you post your OJB.properties settings? When do the error occur single-thread or mult-threaded test, how many concurrent threads?


regards,
Armin


Ashish Rangole wrote:

Thanks for responding Armin.

>
> > Borrow broker from pool failed, using PBKey org.apache.ojb.broker.PBKey:
>
> your PB-pool is exhausted (configured in OJB.properties file), seems you cause an PB-leak (PB.close() was not called) or run an massive multithreaded test.


I am sure I am causing PB-leak because the RDBMS (Oracle) returns error
that max number of processes (150) has been reached.

 > Do you only use the ODMG-api without access of the PB-api?

For all my entities but one, I am using ODMG api. For one entity which
is an enumeration type and is also refered to by all other entities I
use Persistent Broker API.

 Which version

 > of OJB do you use?

I am using db-ojb-1.0.rc6.jar

I now think that perhaps there is something wrong with how I am
creating/closing broker. This is how I am doing right now every time
something has to be retrieved/stored:-

        Implementation odmg      = null;
        Database db              = null;
        Transaction tx           = null;
        PersistenceBroker broker = null;

        Collection list = new ArrayList();
        try {
            odmg = OJB.getInstance();
            db = odmg.newDatabase();
            db.open("default", Database.OPEN_READ_WRITE);

            tx = odmg.newTransaction();
            tx.begin();
            // cast to get internally used PB instance
            broker = ((HasBroker) tx).getBroker();
              :
              :
            [Here I query/lock object to be updated]
              :
              :
            tx.commit();
        } catch ( ODMGException oEx) {
            if (tx != null) {
                tx.abort();
            }


} catch(Exception ex){ if(tx != null){ tx.abort(); }

            ex.printStackTrace();
        }finally {
            try{
                if (db != null) {
                    db.close();
                }
            } catch(ODMGException oEx){
                oEx.printStackTrace();
            }
        }


Places where I need to make a query I do this after tx.begin():->

 broker = ((HasBroker) tx).getBroker();
   :
   :
 QueryByCriteria query = new QueryByCriteria(objectToFind);
 list = broker.getCollectionByQuery(query);

 Here I am not closing the broker explicitly assuming committing the
 transaction or closing the database as above takes care of this.

 Could you please advise here what all I am doing wrong and what is
 causing the leak? I am thinking opening-closing database every time is
 also not a very smart way either. Any advice to improve that will be
 appreciated.

 Thanks for your time and help.

Ashish


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




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




--
--------------------------------------------------
Ashish Rangole
Vexcel Corporation - Image Information Engineering
1690 38th Street, Boulder CO 80301, USA
phone: 303-583-0286 fax: 303-583-0246
Vexcel's home page: http://www.vexcel.com
--------------------------------------------------


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



Reply via email to