(Answer) (Category) FAQ-O-Matic : (Category) Borland Application Server (aka Inprise Application Server, BAS, IAS) :
In the BAS 4.5.1 "pkgen" (Portable Sequence Number Generator) example 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).
From http://groups.google.com/groups?selm=3adc667b_2%40dnews&output=gplain

From: "Krishnan Subramanian" krish@crisp.nl
Newsgroups: borland.public.appserver.ejb-cmp
Subject: portable pkgen (repost)
Date: Tue, 17 Apr 2001 17:50:30 +0100
Message-ID: 3adc667b_2@dnews

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


2001-Sep-04 9:18am gyles19@visi.com


---<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 context1 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 context1 NOT_EXIST --[setContext:setSessionContext]-->
SET_CONTEXT
*st* prepare context1 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 context1 SET_CONTEXT --[create:create]--> READY
*st* prepare context1 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 context2 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 context2 NOT_EXIST --[setContext:setEntityContext]--> POOLED
*st* prepare context2 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 context2 POOLED --[find:ejbFindByPrimaryKey]--> POOLED
*st* prepare context2 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 context2 POOLED --[create:create]--> HALF_CREATED
*st* prepare context2 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 context2 HALF_CREATED --[postCreate:create]--> READY
*st* prepare context2 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 context2 READY --[method:getValueBeforeIncrementingBy]-->
READY
*st* prepare context2 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 context2 READY --[method:getValueBeforeIncrementingBy]-->
READY
*st* prepare context2 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 context2 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 context1 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>--------------------------------


2001-Sep-04 9:19am gyles19@visi.com
[Append to This Answer]
2001-Sep-04 9:19am
Previous: (Answer) I'm trying to get my EJB functions running in JB4 Enterprise. I installed BAS, but now JBuilder won't launch at all. With the -verbose flag I see this: Exception in thread "main" java.lang.NoClassDefFoundError: Files/Inprise/AppServer/console/plugins/iaspt/ini
Next: (Answer) Is it possible to implement custom finder methods on CMP entity beans without losing the other features/methods on the CMP bean?
This document is: http://www.visi.com/~gyles19/cgi-bin/fom.cgi?file=261
[Search] [Appearance]
This is a Faq-O-Matic 2.709.
This FAQ administered by gyles19@visi.com.

Other JBuilder Links

Java Community
Java Tools
Code Central
JB OpenTools
Community
Recent
Threads
Borland Chat
Chat FAQ
Feature Matrices
3.0 |  3.5 |  4.0
5.0 |  6.0 |  7.0
Shop for
JBuilder
JBuilder
Downloads
and reg keys
Report Piracy
Online Manuals
4.0 |  5.0 |  6.0
7.0
Borland
DevSupport's
Bug/RFE Form

Quality Central Client
JB Patches &
Updates
JBuilder FAQs TIs
JBuilder
Newsgroups
Tamaracka's
News Archive
Mr. Haki's
JBuilder Machine
JGuru's
JBuilder FAQ
Sun's Bug
Parade
Netring Home - About - Privacy
The
JBuilder Netring Logo
The Borland JBuilder Netring by JBuilder FAQ-O-Matic
[ Join Now | List Sites | Random | << Prev | Next >> ]
[ Previous 5 Sites | Skip Previous | Skip Next | Next 5 Sites ]