I'm running in WebLogic 7.0sp4 on a two-node cluster, but the problems I'm seeing have raised some generic
J2EE questions in my mind (IOW, not WebLogic-specific).
My EJB app uses a mix of SLSBs and CMP 2.0 entity beans with container-managed transactions, but one of the bean's create methods calls a SLSB to retrieve the next value from an Oracle sequence using
JDBC. The whole system is setup to use a single TxDataSource. Somewhere, connections are being leaked. As usual, I suspect my own code first; then I look elsewhere. There are a few things that look suspicious in the sequence service SLSB, but first let me lay out my assumptions to see if I've just misunderstood the EJB spec.
1. It's okay for JDBC code and CMP beans to use the same TxDataSource.
2. Assuming (1) is true, if a SLSB method marked "Supports" gets called, the connection it acquires from the datasource will be enlisted in the current transaction if there is one. [I think this is my error]
3. If (2) is true, the SLSB method should interact with the connection as any other basic JDBC code would (getConn, execute query, close results, statement and connection). To wit:
Since obtaining the next value from an Oracle sequence is executed "outside" the database transaction (it cannot be rolled back), I marked this method as "Supports" -- it has no effect on nor requires an existing transaction. Is this correct, or must all database accesses be performed in the context of a transaction?
I'm beginning to think this is the problem -- that I must wrap a transaction around any code that will eventually interact with the DB or entity beans, even reading their attributes. I have all of the getters and finders on the entity beans marked as "Supports." Is this not the correct way?
Something that tells me I doing it wrong is that I have some startup code that reads in the lookup code table using entity beans (yes, I know it's overkill, but it should work). It simply does a findAll and iterates through the beans. This is the one place where I skipped creating a DTO in the bean and actually call the five getter methods on each bean. The SLSB method that does this work is marked as "Supports."
What I see is that each bean's ejbStore() method is called after each getter call. It's like WL is creating a transaction, accessing the bean's attribute, and then committing the transaction. I thought that by marking all methods involed with "Supports," no transaction would be begun or committed. Now it looks like WL insists on having an active transaction when accessing an entity bean for any reason. Is this the case?
Thank you in advance for any pointers. I know this is a pretty long and involved post, so if I can clarify anything or post more code, let me know.
Peace!
[ February 04, 2004: Message edited by: David Harkness ]
[ February 04, 2004: Message edited by: David Harkness ]