[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jboss-user
Subject:    Re: [JBoss-user] Re: Help -- Connection Pooling -- Jboss 3.0
From:       David Jencks <davidjencks () directvinternet ! com>
Date:       2002-08-31 4:20:10
[Download RAW message or body]

This certainly looks odd to me, but I don't know what any of the Castor
objects do or represent so I have no basis for thinking it correct or
wrong.  You don't show the code that is supposed to actually close the db
connection.  You might find it and have it print a stack trace when it gets
there.

I haven't personally seen any evidence that Castor works with CMT in jboss
3.

Thanks
david jencks


On 2002.08.30 06:18:00 -0400 Andrew wrote:
> Hi, I've found something strange in DtabaseImpl.java for 0.9.3.21
> release:
> 
>     public synchronized void close()
>         throws PersistenceException
>     {
>         try {
>             if ( _transaction == null ) {
>                 if ( _ctx != null && _ctx.isOpen() ) {
>                     try {
>                         _ctx.rollback();
>                     } catch ( Exception except ) {
>                     }
>                     try {
>                         _ctx.close();// this statement must be executed
>                     } catch ( Exception except ) {
>                     }
>                      throw new PersistenceException(
> "jdo.dbClosedTxRolledback" );
>                 }
>             }
>         } finally {
>             _scope = null;
>         }
>     }
> 
> I can't understand exactly what is method tries to do BUT IMHO
> _ctx.Close()
> MUST be called(for active transaction) before end of transaction in
> session
> bean
> with container managed persistence because
> org.exola.castor.persist.TransactionContext.java
> contains required code for ejb container manged connections:
> 
>     public synchronized void close()
>         throws TransactionAbortedException
>     {
>         Enumeration enum;
>         ObjectEntry entry;
> 
>         if ( _status != Status.STATUS_ACTIVE &&
>              _status != Status.STATUS_MARKED_ROLLBACK ) {
>             throw new IllegalStateException( Messages.message(
> "persist.missingEnd" ) );
>         }
>         try {
>             // Go through all the connections opened in this transaction,
>             // close them one by one.
>             closeConnections();// because of this
> 
>         } catch ( Exception except ) {
>             // Any error that happens, we're going to rollback the
> transaction.
>             _status = Status.STATUS_MARKED_ROLLBACK;
>             throw new TransactionAbortedException(
> Messages.format("persist.nested", except), except );
>         }
>     }
> 
> I think so because in simple scenario in session bean method with CMP I
> do:
> 
> DataSource ds;
> method(){
> try{
>     Connection conn= ds.getConnection();
>     //somthing do with it and...
> }catch(){}
> finally{ conn.close();}//!!! before end of container managed
> transaction(could be Database.close())
> }
> 
> so I suppose that castor do something like this in his DatabaseImpl but
> IT
> IS NOT...
> What could be wrong?
> 
> Best regards.
> 
> ----- Original Message ----- 
> From: "Arijit Ghosh" <arijit.g@svw.com>
> To: "JBoss User" <jboss-user@lists.sourceforge.net>
> Sent: Friday, August 30, 2002 1:12 PM
> Subject: [JBoss-user] Re: Help -- Connection Pooling -- Jboss 3.0
> 
> 
> > Hi,
> > 
> > Castor closes the connection when database.close() i,e, close
> connection
> > is called. I have tested and found that database.close() is called
> > everytime. However, the connection does not return to the jboss pool.
> > David, you have mentioned something about jboss pooling code. Am I
> doing
> > something wrong there ? What code in Jboss ensures that Pooling is used
> > and connections are NOT created everytime ?
> > 
> > This is my jdo-service.xml where I have set "Database Pooling" to true.
> > 
> > <?xml version="1.0" encoding="UTF-8"?>
> > 
> > <server>
> > 
> >  <mbean code="org.jboss.jdo.castor.CastorJDOImpl"
> >        name="DefaultDomain:service=CastorJDO,name=mydb">
> >   <attribute name="Configuration">file:./database.xml</attribute>
> >   <attribute name="JndiName">jdo/mydb</attribute>
> >   <attribute name="LockTimeout">0</attribute>
> >   <attribute name="LoggingEnabled">true</attribute>
> >   <attribute name="CommonClassPath">false</attribute>
> >   <attribute name="AutoStore">false</attribute>
> >   <attribute name="DatabasePooling">true</attribute>
> >  </mbean>
> > 
> > </server>
> > 
> > Do I need to edit some other code to ensure database pooling ?
> > 
> > 
> > Any pointers ?
> > 
> > Regards,
> >   Arijit
> > 
> > 
> > -----------------------
> > To the jboss pooling code, castor is just an app asking for connection
> > handles.  It has to close them to tell the pooling code it is done with
> > the
> > connection and it can be put back in the pool. It looks to me from your
> > report that no connections are being put back in the pool, so I suggest
> > you
> > see if Castor is closing the connections.
> > 
> > david jencks
> > 
> > On 2002.08.29 03:25:15 -0400 Arijit Ghosh wrote:
> > > According to my understanding, Castor is not supposed to close the
> > > connection. This is because I have mentioned in the deployment
> > > descriptor (ejb-jar.xml) ---
> > >
> > >    <resource-ref>
> > >         <res-ref-name>jdo/mydb</res-ref-name>
> > >         <res-type>org.exolab.castor.jdo.DataObjects</res-type>
> > >         <res-auth>Container</res-auth>
> > >     </resource-ref>
> > >
> > > Since the <res-auth> is set to Container, Jboss is supposed to handle
> > > the connections. Isn't it ?
> > >
> > > Regards,
> > >   Arijit
> > >
> > >
> > > ---------------------------------------
> > > I think you will have to read the castor code to find out why it is
> > not
> > > closing connections when it is done with them.
> > >
> > > david jencks
> > >
> > > On 2002.08.29 00:09:30 -0400 Arijit Ghosh wrote:
> > > > There is no connection timeout error.... Connection remains there
> > > > (status =INACTIVE). If I restart Jboss, then a new set of
> > connections
> > > > are being created which again become INACTIVE and never reused.
> When
> > 
> > > the
> > > > no of maximum connections reached, "No Managed Connection" error is
> > > > thrown. So if I have no of MAX connections as 3 then after
> > RESTARTING
> > > > Jboss and making few database transactions, I will have 6 INACTIVE
> > > > connections. (3 from the last and 3 now).
> > > >
> > > > Here is the sample code of what I am doing ----
> > > >
> > > >
> > > >  InitialContext  ctx;
> > > >  DataObjects     dobj;
> > > >  Database db;
> > > >
> > > > //Initializing the context
> > > >  ctx = new InitialContext();
> > > >
> > > > //Looking up for for the dataobject
> > > >  dobj = (DataObjects) ctx.lookup( "java:/comp/env/jdo/mydb" );
> > > >
> > > >
> > > >
> > > >  try
> > > >     {
> > > >        //performing a getDatabase()
> > > >       db = dobj.getDatabase();
> > > >
> > > >        //No need for db.begin() No need for transaction.begin()
> > > >       findOql = db.getOQLQuery(aQuery);
> > > >
> > > >       // Executing the Query
> > > >       results = findOql.execute(Database.ReadOnly);
> > > >
> > > >     //No need for transaction.commit() or db.commit()
> > > >
> > > >     }
> > > >     catch(Exception e)
> > > >     {
> > > >       if(e instanceof java.lang.IllegalStateException)
> > > >         throw new CastorException("error.jdoIllegalState", e);
> > > >       else
> > > >         throw new CastorException("error.generalJDOError", e);
> > > >     }finally{
> > > >       try
> > > >       {
> > > >         //database connection is being closed here
> > > >         if(db!=null) db.close();
> > > >       }
> > > >       catch(PersistenceException e)
> > > >       {
> > > >         throw new CastorException("error.generalJDOError",e);
> > > >       }
> > > >     }
> > > >
> > > > Any suggestions ???
> > > >
> > > > Regards,
> > > >   Arijit
> > > >
> > > > --------------------
> > > > Hi,
> > > >
> > > >   I am using Jboss 3.0 with Castor. I am using CMT.
> > > >
> > > > As the transaction is Container Managed, I am not opening any
> > > > transaction explicitly nor am I closing it. Neither am I opening a
> > > > database connection or doing a database.begin().
> > > >
> > > > Also, I am not performing database.commit().
> > > >
> > > > However, I am performing database.close() and this statement always
> > > gets
> > > >
> > > > executed as I have put it in "finally"
> > > >
> > > > I find that if I make any database call, the database gets updated
> > > > correctly. However, the connnection remains with status = INACTIVE.
> > > >
> > > > As a result, if I have set Max number of Connections to "3" in my
> > > > Oracle-service.xml file then I am getting a "No Managed Connection"
> > > > error after 3 successful connections are met.
> > > >
> > > > Can anyone help ? Why are the connections not being reused ? or
> > > removed
> > > > ?
> > >
> > 
> > 
> > 
> > -------------------------------------------------------
> > This sf.net email is sponsored by: OSDN - Tired of that same old
> > cell phone?  Get a new here for FREE!
> > https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
> > _______________________________________________
> > JBoss-user mailing list
> > JBoss-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/jboss-user
> > 
> > 
> > 
> 
> 
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by: OSDN - Tired of that same old
> cell phone?  Get a new here for FREE!
> https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
> _______________________________________________
> JBoss-user mailing list
> JBoss-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jboss-user
> 
> 


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic