-----Original Message-----
From: Bolt, Dave [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 18, 2001 3:28 PM
To: jBoss
Subject: RE: [jBoss-User] BMP and Container Managed TransactionsI found that someone else has encountered this problem before. In this case it was a
stateless session bean which created a CMP entity bean A which created 3 other CMP
entity beans in it's ejbStore method.http://www.mail-archive.com/[email protected]/msg07146.html
My situation is similar I have a business method of a session bean which is calling
the create methods of two BMP entity beans is rapid fire fashion. The second entity
bean cannot be created until the first entity bean has updated the database. My goal
is that the session bean is a facade object which will guarantee that the entities
are created or rollback them all. Is this an unusual pattern for EJB when you have
what basically is a dependent object Entity bean?Dave
-----Original Message-----
From: Bolt, Dave [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 18, 2001 1:33 PM
To: jBoss
Subject: RE: [jBoss-User] BMP and Container Managed Transactions was "Find er Methods are sl ower when nothing is returned"
I tried making the changes. I even have tried the following the session bean is ddc/DocumentLoader and the
entities are ddc/Product and ddc/DocumentVersion. The session bean has valid ejb-ref entries for the two entity
beans as well. As I understand it, the declarations below should tell the container that all of the Home and
Remote interfaces of all of the Beans require a transaction.BTW, I am not including any jboss.xml or jaws.xml files in my EJB jar
Even with all of this, I have no success. The SQL code in the ejbCreate method of DocumentVersion times out
on the INSERT statement because the Product record created by the ejbCreate method of Product has not yet
been committed.I tried changing the isolation setting in Oracle, but the driver only supports READ_COMMITTED and SERIALIZABLE,
the default setting being READ_COMMITTEDI agree the EJX tool in JBOSS 2.0 FINAL is buggy. I tend to do most of the coding of the descriptor by hand.
<assembly-descriptor>
<container-transaction>
<description>Required</description>
<method>
<ejb-name>ddc/DocumentPart</ejb-name>
<method-name>*</method-name>
</method>
<method>
<ejb-name>ddc/Product</ejb-name>
<method-name>*</method-name>
</method>
<method>
<ejb-name>ddc/DocumentPartMedia</ejb-name>
<method-name>*</method-name>
</method>
<method>
<ejb-name>ddc/DocumentLoader</ejb-name>
<method-name>*</method-name>
</method>
<method>
<ejb-name>ddc/DocumentVersion</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>-----Original Message-----
From: Nortje, Andrew [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 18, 2001 12:13 PM
To: 'jBoss'
Subject: RE: [jBoss-User] BMP and Container Managed Transactions was "Find er Methods are sl ower when nothing is returned"
Dave
I think the problem may be in the way you have configured the transactions in jBoss.
Use the ejx GUI for configuring transactions. I use an older ejx, the one that comes with jBoss 2.0 FINAL I think is broken or partially broken.
Make the method on your session bean Required. That way it will start a transaction if one does not exist and all subsequent operations will be under that transaction. Make sure other methods, that need to be part of the same transaction, are also marked Required. I don't believe jBoss is behaving badly, as I say I have this sort of thing working. Check your config carefully.
An example of some ejb-jar.xml config for transactions
<assembly-descriptor>
<container-transaction>
<description>Required</description>
<method>
<ejb-name>Customer</ejb-name>
<method-intf>Home</method-intf>
<method-name>buy</method-name>
<method-params>
<method-param>com.uni.trader.ShoppingCart</method-param>
<method-param>com.uni.account.PaymentDetails</method-param>
</method-params>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
-----Original Message-----
From: Bolt, Dave [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 18, 2001 11:10 AM
To: jBoss
Subject: RE: [jBoss-User] BMP and Container Managed Transactions was "Find er Methods are sl ower when nothing is returned"
I tried changing the beans to reentrant = true. I did have them marked as non-reentrant. Unfortunately it did not fix the problem. My create methods are setting all of the attribute data.
Here's the basic issue. It looks like the connection pool is giving me different connections for each of my beans. As a result the SQL in the beans is isolated transactionally from the other beans. I guess the basic question is this. If I have BMP entity beans, running under container-managed transactions. And if I have beans that have dependency relationships (For example a foreign-key relationship in the DB) in the back-end database. How do I write my SQL and connection pool code so that the beans work properly in the EJB transaction context. Is my only option to choose a isolation level that allows dirty reads?
How do I set the isolation level in my jboss configuration? (Since the JBOSS web site is down, I can't look at the docs)
Do I have to do it manually via the Connection setTransactionIsolation method any time I lookup a connection?
What if I have a mix of BMP, CMP, and (horror) SQL in a SessionBean?Thanks
Dave
-----Original Message-----
From: Nortje, Andrew [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 18, 2001 10:20 AM
To: 'jBoss'
Subject: RE: [jBoss-User] BMP and Container Managed Transactions was "Find er Methods are sl ower when nothing is returned"
Dave
I am doing something similar to what you are and it works after much struggling i.e. I create and use beans under a single transaction context. If something fails created rows are rolled back etc.
Anyway I recognize the timeout error, I also had this error. It turned out I was making reentrant calls to my entity beans and they were not marked reentrant. You may have a similar problem. Try make your entity beans reentrant (ejb-jar.xml) then test your code. If it then works then you are making reentrant calls, you can then take it from there.
Also make sure your create() method correctly populates all the bean data (attributes), i.e. after create() the bean instance is taken out the pool and is assigned.
-----Original Message-----
From: Bolt, Dave [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 18, 2001 9:21 AM
To: jBoss
Subject: [jBoss-User] BMP and Container Managed Transactions was "Finder Methods are sl ower when nothing is returned"
It turns out that it is a database thing, but then again it isn't. Here's a better description.
I have three EJBs, a session bean and two entity beans. The entity beans have a one-to-many relationship. If I had EJB 2.0 I would use the container managed relationship features to handle all of this. Right now, it's being done the hard way with BMP code. Anyway, the session bean has a business method marked with a RequiresNew transaction attribute and it calls the create method of first the master bean and then the entity bean. In the database (Oracle 8i) the detail records can only exist if the master record exists (foreign key constraint).
Each of the entity beans obtains a connection from the connection pool with the following code.
private Connection getConnection()
{
Context ctx = null;
Connection con = null;
DataSource ds = null;
try
{
ctx = new InitialContext();ds = (DataSource)ctx.lookup(JNDINames.DB_POOL);
con = ds.getConnection();return con;
}
catch(NamingException ne)
{
System.out.println(ne.getMessage());
System.out.println(ne.getExplanation());
ne.printStackTrace();
throw new EJBException(ne);
}
catch(SQLException se)
{
System.out.println(se.getMessage());
se.printStackTrace();
throw new EJBException(se);
}}
The problem that I am having is that the create method of the master bean is adding records to the database, but the changes are not visible to the detail bean via it's connection. It could be an isolation level thing (I haven't found in JBOSS were you set the isolation level for an Oracle connection pool).
What I want to have happen is that the Session bean will start a transaction (RequiresNew) which will include the create methods of the Master and Detail beans (Requires), but it looks like since I am getting different connections from the connection pool that the ability of the container to manage the transactions is being
compromised. The error that I finally get in my code is ORA-02049: timeout: distributed transaction waiting for lock.
Any ideas?
Dave
-----Original Message-----
From: Cook, Thomas [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 17, 2001 6:24 PM
To: 'jBoss'
Subject: RE: [jBoss-User] Finder Methods are slower when nothing is return ed
Possible a database thing? If nothing is returned, maybe it is doing a sequential search?
Tom
--
Tom Cook
Systems Development
Australian Submarine Corporation
Mersey Road
Outer Harbour
+61 8 8348 7645
"From the instant I picked your book up, until the moment I put it down, I was convulsed with laughter. I fully intend to read it one day."- Groucho Marx
-----Original Message-----
From: Bolt, Dave [SMTP:[EMAIL PROTECTED]]
Sent: Thursday, January 18, 2001 5:01 AM
To: [EMAIL PROTECTED]
Subject: [jBoss-User] Finder Methods are slower when nothing is returned
I'm trying to write some code to use BMP Entity beans to update an Oracle 8i database.
I have a session bean that is doing the data loading from an XML file. I want to use the Entity
bean to see if the data exists (via a Finder method) and then either create or update the
record depending on the status.
I am seeing that performance is very fast if the record already exists, whereas it is very slow if no
records can be found. Has anyone else noticed a difference in performance in the Finder's thanks
Dave Bolt
There is always bandwidth, just none for you.
Title: RE: [jBoss-User] BMP and Container Managed Transactions
More
news on my issue.
I
added a SetRollbackOnly() call to the ejbCreate method of my second entity bean.
When the
Oracle
error is detected "ORA-02049: timeout: distributed transaction waiting for
lock", I tell
the
transaction to rollback. The rollback actually works, the inserts created via
the first
entity
bean (which the second bean is dependent on) are in fact rolled
back.
So
jBoss is managing the overall transaction involving my session bean and entity
bean's. The
problem seems to be that the second entity bean cannot see the
uncommitted changes of the
first
bean.
In my
code, I always obtain a connection from the Connection Pool at the start of the
ejbCreate
method. Is this the appropriate place?
Shouldn't a connection to a managed resource such as a connection pool be
tied to my
transactional context? In other words, If I have three beans in a
transaction and they all
use
the same connection pool, shouldn't they all get a copy of the same exact
database
transaction.
If not, then how do people right EJB apps
against Oracle that use Oracle's
oracle.jdbc.xa.OracleXid XA resource driver. I'm also using the following
Oracle
driver
oracle.jdbc.xa.client.OracleXADataSource. As best as I know the drivers
were
set up
in accordance with what was in the jBoss documentation.
Dave
- RE: [jBoss-User] BMP and Container Managed Transactions Bolt, Dave
- [jBoss-User] Castor JDO - IllegalStateException Andrew Taylor
- Re: [jBoss-User] BMP and Container Managed Transaction... Bolt, Dave
- RE: [jBoss-User] BMP and Container Managed Transaction... Bolt, Dave
- RE: [jBoss-User] BMP and Container Managed Transaction... Nortje, Andrew
- RE: [jBoss-User] BMP and Container Managed Transaction... Bolt, Dave
