Question : Deadlock & multiple resources error

Hi

I'm using WebSphere Portal Server, WebSphere Application Server, EJB with DB2.

All the applications will do transaction (Insert / update /delete) using EJB. but some of the selection will still be done using normal query.

however, i keep having 2 types of error:
1) Deadlock
2) illegal attempt to use multiple resources

below are the log on error (2)

*********************************************
TransactionIm E WTRN0062E: An illegal attempt to use multiple resources that have only one-phase capability has occurred within a global transaction.
[7/13/04 17:56:56:451 SGT]   2612ad LocalTransact E J2CA0030E: Method enlist caught java.lang.IllegalStateException
      at com.ibm.ejs.jts.jta.TransactionImpl.enlistResource(TransactionImpl.java:546)
      at com.ibm.ejs.jts.jta.JTSXA.enlistResource(JTSXA.java:1061)
      at com.ibm.ejs.jts.jta.JTSXA.enlistOnePhase(JTSXA.java:1038)
      at com.ibm.ejs.j2c.LocalTransactionWrapper.enlist(LocalTransactionWrapper.java:504)
      at com.ibm.ejs.j2c.ConnectionEventListener.interactionPending(ConnectionEventListener.java:711)
      at com.ibm.ws.rsadapter.spi.WSRdbManagedConnectionImpl.processInteractionPendingEvent(WSRdbManagedConnectionImpl.java:1173)
      at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.beginTransactionIfNecessary(WSJdbcConnection.java:307)
      at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1255)
      at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1222)
 :
 :
 :
while trying to enlist resources from datasource jdbc/tibsdb with the Transaction Manager for the current transaction, and threw a Exception.

*************************************************

Question:
1) what are the "Correct" steps to be done to avoid these errors?
2) i'm having more than one web project. is that the cause of these errors?

need the solution urgently. would appreciate if there is a step by step guide.

Thanks

PS. if the problems can be solved totally, would increase the points.

Answer : Deadlock & multiple resources error

a few thoughts and questions:

so despite all these permutations, your table just has one column with the sequence number, or does it have different columns which are used for different types?

DB2 version 8 has a sequence object.  It is not a table but it is a database object.  It has caching (which can be turned on and off) and is very scalable.  You can set it up to cycle.  You can set the increment, the min and max values, the order.  To get a value, just call select nextval for seq_1.

Creation:

CREATE SEQUENCE seq_1 AS INT
   START WITH 1
   INCREMENT BY 1
   MINVALUE 1
   NO MAXVALUE
   NO CYCLE
   NO CACHE
   ORDER

Use:

select nextval for seq_1

Another alternative:  since DB2 doesn't seem to handle the deadlock issue very well (instead of making you wait it just kicks you out), why not set up some type of Singleton object with sychronized methods and thread flags that makes threads wait until they can have access to your table.  I was able to accomplish this on a multi-threaded insert program.  However, I always felt like DB2 should have done this for me.

Regarding entity bean:  why haven't you been able to create an entity bean with identity.  Why not use Bean Managed Persistence?  Then in the ejbCreate() method, just do a "insert into x values (default,x,y,z)".  If your app uses CMP, you could still have just one bean that's BMP.


Random Solutions  
 
programming4us programming4us