wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes how to start a transaction from client side in CMT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "how to start a transaction from client side in CMT" Watch "how to start a transaction from client side in CMT" New topic
Author

how to start a transaction from client side in CMT

james edwin
Ranch Hand

Joined: Nov 22, 2001
Posts: 393
I made small program in EJB2.0(Stateful SB and it's CMT ) and it's working fine and transaction attribute is "Required" for the bussinees method. But when i make this transaction attribute "Mandatory" i get the following error :-

Exception message CORBA TRANSACTION_REQUIRED 9998 Maybe

...Now i am thinking what i do that client can start transaction.I am using Sun J2EE server(1.3)..i have checked all the setting,not able to find any option,where client can start transaction ? How client will start transaction ?

Regards,

James


Regards,
James
james edwin
Ranch Hand

Joined: Nov 22, 2001
Posts: 393
NOW, I have done some R & D and when i call METHOD B() (Tx attribute Mandatory) from Method A() (Tx attribute Required).

Method A(tx attribute Required) calls Method B (tx attribute Mandatory)

It worked...but now the question is if i call Method B directly from JSP or Servlet it throws error.

So is client here means EJB only ? or we can JSP or servlet as a client too when we talk of transactions attributes

Regards,

James
[ June 03, 2004: Message edited by: james edwin ]
v Gupta
Greenhorn

Joined: May 26, 2004
Posts: 8
Mandatory transaction required means, the method for which this attribute has been defined must be called from a transaction and that transaction should have been started from EJB, not from Servlet or JSP
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
The client must be in a transaction, that is why you are getting an exception.

For a client outside the EJB container, you need a UserTransaction in order to start a transaction. I don't know how it works in other containers, but for WebLogic the client uses JNDI to obtain a reference to the UserTransaction object for the WebLogic Server domain. Once this reference is obtained, and cast to UserTransaction, then you invoke its begin() method to start the transaction. The EJB can then be invoked and it will run in the client transaction.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
james edwin
Ranch Hand

Joined: Nov 22, 2001
Posts: 393
Hi Roger,

Thanks for explaination.But just need one clarification,how can we use JNDI to get reference to UserTransaction ?What all values we put ?

Regards,

James
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
The values depend on your system, but here's an example.

 
Don't get me started about those stupid light bulbs.
 
subject: how to start a transaction from client side in CMT
 
Similar Threads
SessionSynchronization interface and stateless session bean
How can i rollback the Transactions when using with CMT in EJB3.0
can non-ejb client pass its transaction to ejb?
How to identify existing Transaction?
TRANSACTION CONTEXT