Skip to main content

Configuring global transactions

2 replies [Last post]
riksweeney
Offline
Joined: 2007-07-30
Points: 0

Hi,

I'm trying to migrate one of our applications from Weblogic to Glassfish with the intention of upgrading it from EJB 2.1 to EJB 3. I'm having problems configuring global transactions for Oracle. In one part of the application, we create an Entity bean and store it in the database, later on in the transaction, we use a session bean to insert some data (the connection is obtained from the same datasource that the Entity bean uses), but get a foreign key constraint error because the operations don't appear to be part of the same transaction.

I've set up my data source as follows (also see attached):

Resource Type: javax.sql.DataSource
Datasource Classname: oracle.jdbc.pool.OracleDataSource
Non Transactional Connections: Disabled
Transaction Isolation: Default level
Isolation Level: Guaranteed

If anyone can help shed some light on how I can get these transactions working I'd be very grateful.

Thanks

Richard

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
mvatkina
Offline
Joined: 2005-04-04
Points: 0

Do you pass the connection around? In GlassFish the connection is bound
to a method invocation and needs to be acquired in the method in which
it is being used and closed at the end of that method.

-marina

On 3/8/13 3:39 AM, forums@java.net wrote:
> Hi, I'm trying to migrate one of our applications from Weblogic to
> Glassfish
> with the intention of upgrading it from EJB 2.1 to EJB 3. I'm having
> problems
> configuring global transactions for Oracle. In one part of the
> application,
> we create an Entity bean and store it in the database, later on in the
> transaction, we use a session bean to insert some data (the connection is
> obtained from the same datasource that the Entity bean uses), but get a
> foreign key constraint error because the operations don't appear to be
> part
> of the same transaction. I've set up my data source as follows (also see
> attached): Resource Type: javax.sql.DataSource Datasource Classname:
> oracle.jdbc.pool.OracleDataSource Non Transactional Connections: Disabled
> Transaction Isolation: Default level Isolation Level: Guaranteed If
> anyone
> can help shed some light on how I can get these transactions working
> I'd be
> very grateful. Thanks Richard
>
> --
>
> [Message sent by forum member 'riksweeney']
>
> View Post: http://forums.java.net/node/895526
>
>

riksweeney
Offline
Joined: 2007-07-30
Points: 0

The connection is not passed around, I look up my datasource in my session bean, i.e.

Context ctx = new InitialContext();

DataSource ds = (DataSource)ctx.lookup("jdbc/myDatasource");

Connection conn = ds.getConnection();

The entity beans use the same datasource, so I guessing I've misconfigured something in my migration from Weblogic.