Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

portable pkgen (repost)

3 views
Skip to first unread message

Krishnan Subramanian

unread,
Apr 17, 2001, 12:50:30 PM4/17/01
to
repost from the b.p.a.install-examples (no one answered :(

hi borland,

i was just going through the pkgen example -
the Portable Sequence Number Generator.

BAS 4.5.1
Sun JDK 1.3
NT 4 Workstation + SP6

Problem:
when a row does *not* exist in the "Sequence" table
(say an empty sequence table to start with)
and a call to the SequenceGenerator SLSB occurs

getNextSequenceNumber("Employee"),

the container throws a javax.transaction.InvalidTransactionException
(see below for complete server side debug trace).

the above is the *only* case when i run into
a concurrency exception which i cannot get
out of - no matter how high i set the retry count
to be. (tried a value of 1000)

the row is created in the 'Sequence' table though since
this happens before the concurrency exception checking
and subsequent calls to get the next sequence work correctly

The transaction attribute for the SLSB (SequenceGenerator) is
"Required" and for the Sequence entity bean is "RequiresNew".
(as per the docs)

the error disappears when the transaction attribute
for the Sequence Entity bean's home interface methods
are set to "Required" and the remote interface methods
(including the getValueBeforeIncrementingBy) are set
to "RequiredNew". (which i suspect is the cause of
the error since the create() is in one transaction while
the incrementing is in another?)

btw a small bug in the SLSB (SequenceGeneratorBean):
the line "if(entry.last > entry.first + _blockSize)"
should read(entry.last >= entry.first + _blockSize)"
otherwise duplicates are generated at the block size
boundary when a trip to the db occurs.

-krish

---<Server side debug>--------------------------------
*sc* received request: CORBA::Object.root_context
*sc* received request: CORBA::Object.resolve
*sc* received request: CORBA::Object._is_a
*sc* received request: CORBA::Object.create
*sc* received request: CORBA::Object.getNextSequenceNumber
StatelessSessionHome.ServantLocator.preinvoke: getNextSequenceNumber
*st* prepare context<1> NOT_EXIST --[setContext:setSessionContext]-->
SET_CONTEXT
Invoking method void
com.foliquest.pkgen.SequenceGenerator.setSessionContext(javax.ejb.SessionCon
text=SessionContext[id=1,state=NOT_EXIST])
completed
com.foliquest.pkgen.SequenceGenerator.setSessionContext()
*st* commit context<1> NOT_EXIST --[setContext:setSessionContext]-->
SET_CONTEXT
*st* prepare context<1> SET_CONTEXT --[create:create]--> READY
Invoking method com.foliquest.pkgen.SequenceGeneratorRemote
com.foliquest.pkgen.SequenceGenerator.create()
result com.foliquest.pkgen.SequenceGeneratorRemote=null
com.foliquest.pkgen.SequenceGenerator.create()
*st* commit context<1> SET_CONTEXT --[create:create]--> READY
*st* prepare context<1> READY --[method:getNextSequenceNumber]--> READY
*tx* Dispatcher.invoke: tx.begin(serverTransaction)
Invoking method int
com.foliquest.pkgen.SequenceGenerator.getNextSequenceNumber(java.lang.String
=Employee)
transaction attribute Required
transaction status StatusActive
*st* prepare context<2> NOT_EXIST --[setContext:setEntityContext]--> POOLED
*tx* Dispatcher.invoke: tx.suspend(callerTransaction)
Invoking method void
com.foliquest.pkgen.Sequence.setEntityContext(javax.ejb.EntityContext=Entity
Context[id=2,state=NOT_EXIST])
completed com.foliquest.pkgen.Sequence.setEntityContext()
*tx* Dispatcher.invoke: tx.resume(callerTransaction)
*st* commit context<2> NOT_EXIST --[setContext:setEntityContext]--> POOLED
*st* prepare context<2> POOLED --[find:ejbFindByPrimaryKey]--> POOLED
*tx* Dispatcher.invoke: tx.suspend(callerTransaction)
*tx* Dispatcher.invoke: tx.begin(serverTransaction)
Invoking method com.foliquest.pkgen.SequenceRemote
com.foliquest.pkgen.Sequence.ejbFindByPrimaryKey(java.lang.String=Employee)
transaction attribute RequiresNew
transaction status StatusActive
*cm* findByPrimaryKey(java.lang.String name): SELECT name, tableIndex FROM
Sequence WHERE name = ?; args: [java.lang.String name]
*cm* datasource: jdbc/fisdb
*cm* reuseStatements: true
*cm* dialect: none
*cm* pk fields: java.lang.String name
*cm* cm fields: int tableIndex
*cm* create: INSERT INTO Sequence (name, tableIndex) VALUES (?, ?)
*cm* remove: DELETE FROM Sequence WHERE name = ?
*cm* findByPrimaryKey: SELECT name, tableIndex FROM Sequence WHERE name = ?
*cm* load: SELECT tableIndex FROM Sequence WHERE name = ?
*cm* store: UPDATE Sequence SET tableIndex = ? WHERE name = ?
*cm* execute findByPrimaryKey(java.lang.String name) "SELECT name,
tableIndex FROM Sequence WHERE name = ?" args: [Employee]
call threw exception com.foliquest.pkgen.Sequence.ejbFindByPrimaryKey()
*tx* Dispatcher.invoke: tx.commit(serverTransaction)
*tx* Dispatcher.invoke: tx.resume(callerTransaction)
*st* commit context<2> POOLED --[find:ejbFindByPrimaryKey]--> POOLED
*st* prepare context<2> POOLED --[create:create]--> HALF_CREATED
*tx* Dispatcher.invoke: tx.suspend(callerTransaction)
*tx* Dispatcher.invoke: tx.begin(serverTransaction)
Invoking method com.foliquest.pkgen.SequenceRemote
com.foliquest.pkgen.Sequence.create(java.lang.String=Employee)
transaction attribute RequiresNew
transaction status StatusActive
*cm* execute findByPrimaryKey(java.lang.String name) "SELECT name,
tableIndex FROM Sequence WHERE name = ?" args: [Employee]
*cm* execute create "INSERT INTO Sequence (name, tableIndex) VALUES (?, ?)"
args: [Employee]:[0]
result com.foliquest.pkgen.SequenceRemote=Employee
com.foliquest.pkgen.Sequence.create()
*tx* Dispatcher.invoke: tx.commit(serverTransaction)
*tx* Dispatcher.invoke: tx.resume(callerTransaction)
*st* commit context<2> POOLED --[create:create]--> HALF_CREATED
*st* prepare context<2> HALF_CREATED --[postCreate:create]--> READY
*tx* Dispatcher.invoke: tx.suspend(callerTransaction)
*tx* Dispatcher.invoke: tx.begin(serverTransaction)
Invoking method com.foliquest.pkgen.SequenceRemote
com.foliquest.pkgen.Sequence.create(java.lang.String=Employee)
transaction attribute RequiresNew
transaction status StatusActive
result com.foliquest.pkgen.SequenceRemote=null
com.foliquest.pkgen.Sequence.create()
*tx* Dispatcher.invoke: tx.commit(serverTransaction)
*tx* Dispatcher.invoke: tx.resume(callerTransaction)
*st* commit context<2> HALF_CREATED --[postCreate:create]--> READY
*st* prepare context<2> READY --[method:getValueBeforeIncrementingBy]-->
READY
*tx* Dispatcher.invoke: tx.suspend(callerTransaction)
*tx* Dispatcher.invoke: tx.begin(serverTransaction)
*tx* Dispatcher.invoke: tx.commit(serverTransaction)
*tx* Dispatcher.invoke: tx.resume(callerTransaction)
*st* commit context<2> READY --[method:getValueBeforeIncrementingBy]-->
READY
*st* prepare context<2> READY --[method:getValueBeforeIncrementingBy]-->
READY
*tx* Dispatcher.invoke: tx.suspend(callerTransaction)
*tx* Dispatcher.invoke: tx.begin(serverTransaction)
*tx* Dispatcher.invoke: tx.commit(serverTransaction)
*tx* Dispatcher.invoke: tx.resume(callerTransaction)
*st* commit context<2> READY --[method:getValueBeforeIncrementingBy]-->
READY
*st* prepare context<2> READY --[method:getValueBeforeIncrementingBy]-->
READY
*tx* Dispatcher.invoke: tx.suspend(callerTransaction)
*tx* Dispatcher.invoke: tx.begin(serverTransaction)
*tx* Dispatcher.invoke: tx.commit(serverTransaction)
*tx* Dispatcher.invoke: tx.resume(callerTransaction)
*st* commit context<2> READY --[method:getValueBeforeIncrementingBy]-->
READY
call threw exception
com.foliquest.pkgen.SequenceGenerator.getNextSequenceNumber()
>>>> EJB LOG >>>>
A non application exception was thrown by the method: public abstract int
com.foliquest.pkgen.SequenceGeneratorRemote.getNextSequenceNumber(java.lang.
String) throws java.rmi.RemoteException
java.rmi.ServerException: null; nested exception is:
javax.transaction.InvalidTransactionException: CORBA INVALID_TRANSACTION
0[Cannot invoke a bean first in one transaction, and then in another]
javax.transaction.InvalidTransactionException: CORBA INVALID_TRANSACTION
0[Cannot invoke a bean first in one transaction, and then in another]
at java.lang.reflect.Constructor.newInstance(Native Method)
at com.inprise.vbroker.rmi.CORBA.UtilImpl.newInstance(UtilImpl.java:99)
at
com.inprise.vbroker.rmi.CORBA.UtilImpl._mapSystemException(UtilImpl.java:355
)
at
com.inprise.vbroker.rmi.CORBA.UtilImpl.mapSystemException(UtilImpl.java:572)
at javax.rmi.CORBA.Util.mapSystemException(Util.java:67)
at
com.foliquest.pkgen._SequenceRemote_Stub.getValueBeforeIncrementingBy(_Seque
nceRemote_Stub.java:68)
at
com.foliquest.pkgen.SequenceGenerator.getNextSequenceNumber(SequenceGenerato
r.java:85)
at java.lang.reflect.Method.invoke(Native Method)
at com.inprise.ejb.ConcreteMethod.invoke(ConcreteMethod.java:25)
at com.inprise.ejb.EJBContext.invoke(EJBContext.java:129)
at com.inprise.ejb.Dispatcher.doInvoke(Dispatcher.java:1055)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:572)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:548)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:255)
at
com.foliquest.pkgen.SequenceGeneratorRemotePOAInvokeHandler.getNextSequenceN
umber(SequenceGeneratorRemotePOAInvokeHandler.java:35)
at
com.foliquest.pkgen.SequenceGeneratorRemotePOAInvokeHandler.getNextSequenceN
umber(SequenceGeneratorRemotePOAInvokeHandler.java:69)
at
com.foliquest.pkgen.SequenceGeneratorRemotePOA._invoke(SequenceGeneratorRemo
tePOA.java:63)
at
com.foliquest.pkgen.SequenceGeneratorRemotePOA._invoke(SequenceGeneratorRemo
tePOA.java:43)
at com.inprise.vbroker.poa.POAImpl.invoke(POAImpl.java:2355)
at
com.inprise.vbroker.poa.ActivationRecord.invoke(ActivationRecord.java:104)
at
com.inprise.vbroker.poa.ServerInterceptorManager$ARWrapper.invoke(ServerInte
rceptorManager.java:64)
at
com.inprise.vbroker.GIOP.GiopProtocolAdapter.doRequest(GiopProtocolAdapter.j
ava:492)
*tx* Dispatcher.invoke: tx.setRollbackOnly()
at
com.inprise.vbroker.IIOP.ServerProtocolAdapter.doRequest(ServerProtocolAdapt
er.java:64)
at
com.inprise.vbroker.GIOP.GiopProtocolAdapter.dispatchMessage(GiopProtocolAda
pter.java:653)
at
com.inprise.vbroker.orb.TPDispatcherImpl$TPDispatcher.run(TPDispatcherImpl.j
ava:99)
at com.inprise.vbroker.orb.ThreadPool$PoolWorker.run(ThreadPool.java:76)
<<<< EJB LOG <<<<
>>>> EJB LOG >>>>
Throwing java.rmi.RemoteException for the container-started transaction for
method: public abstract int
com.foliquest.pkgen.SequenceGeneratorRemote.getNextSequenceNumber(java.lang.
String) throws java.rmi.RemoteException
java.rmi.ServerException: null; nested exception is:
javax.transaction.InvalidTransactionException: CORBA INVALID_TRANSACTION
0[Cannot invoke a bean first in one transaction, and then in another]
javax.transaction.InvalidTransactionException: CORBA INVALID_TRANSACTION
0[Cannot invoke a bean first in one transaction, and then in another]
at java.lang.reflect.Constructor.newInstance(Native Method)
at com.inprise.vbroker.rmi.CORBA.UtilImpl.newInstance(UtilImpl.java:99)
at
com.inprise.vbroker.rmi.CORBA.UtilImpl._mapSystemException(UtilImpl.java:355
)
at
com.inprise.vbroker.rmi.CORBA.UtilImpl.mapSystemException(UtilImpl.java:572)
at javax.rmi.CORBA.Util.mapSystemException(Util.java:67)
at
com.foliquest.pkgen._SequenceRemote_Stub.getValueBeforeIncrementingBy(_Seque
nceRemote_Stub.java:68)
at
com.foliquest.pkgen.SequenceGenerator.getNextSequenceNumber(SequenceGenerato
r.java:85)
at java.lang.reflect.Method.invoke(Native Method)
at com.inprise.ejb.ConcreteMethod.invoke(ConcreteMethod.java:25)
at com.inprise.ejb.EJBContext.invoke(EJBContext.java:129)
at com.inprise.ejb.Dispatcher.doInvoke(Dispatcher.java:1055)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:572)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:548)
at com.inprise.ejb.Dispatcher.invoke(Dispatcher.java:255)
at
com.foliquest.pkgen.SequenceGeneratorRemotePOAInvokeHandler.getNextSequenceN
umber(SequenceGeneratorRemotePOAInvokeHandler.java:35)
at
com.foliquest.pkgen.SequenceGeneratorRemotePOAInvokeHandler.getNextSequenceN
umber(SequenceGeneratorRemotePOAInvokeHandler.java:69)
at
com.foliquest.pkgen.SequenceGeneratorRemotePOA._invoke(SequenceGeneratorRemo
tePOA.java:63)
at
com.foliquest.pkgen.SequenceGeneratorRemotePOA._invoke(SequenceGeneratorRemo
tePOA.java:43)
at com.inprise.vbroker.poa.POAImpl.invoke(POAImpl.java:2355)
at
com.inprise.vbroker.poa.ActivationRecord.invoke(ActivationRecord.java:104)
at
com.inprise.vbroker.poa.ServerInterceptorManager$ARWrapper.invoke(ServerInte
rceptorManager.java:64)
at
com.inprise.vbroker.GIOP.GiopProtocolAdapter.doRequest(GiopProtocolAdapter.j
ava:492)
*tx* Dispatcher.doInvoke: discarding the instance
*st* commit context<1> READY --[kill]--> KILLED
*tx* Dispatcher.invoke: tx.rollback(serverTransaction)
StatelessSessionHome.ServantLocator.postinvoke: getNextSequenceNumber
at
com.inprise.vbroker.IIOP.ServerProtocolAdapter.doRequest(ServerProtocolAdapt
er.java:64)
at
com.inprise.vbroker.GIOP.GiopProtocolAdapter.dispatchMessage(GiopProtocolAda
pter.java:653)
at
com.inprise.vbroker.orb.TPDispatcherImpl$TPDispatcher.run(TPDispatcherImpl.j
ava:99)
at com.inprise.vbroker.orb.ThreadPool$PoolWorker.run(ThreadPool.java:76)
<<<< EJB LOG <<<<
---</Server side debug>--------------------------------


0 new messages