Fernando Koch wrote:
>
> Hello,
> I have some problems when trying to run the ClientOp example in JOnAS 2.2.2
> . I've tried running it with JOnAS 2.1.1 and it ran successfully.
>
> I have configured JOnAS with the following settings:
>
> <ejb-jar>
> <description>Deployment descriptor for the sb JOnAS example</description>
> <enterprise-beans>
> ...
> <transaction-type>Container</transaction-type>
> </enterprise-beans>
> <assembly-descriptor>
> ...
> <container-transaction>
> <method>
> <ejb-name>Op</ejb-name>
> <method-name>buy</method-name>
> </method>
> <trans-attribute>Required</trans-attribute>
> </container-transaction>
> </assembly-descriptor>
> </ejb-jar>
>
> As far as I understand, this means that when I use my ClientOp, then the
> Container should create a UserTransaction object. However, this doesn't
> happen. The following code describes what I'm trying to do:
> UserTransaction utx = null;
> try {
> utx = (UserTransaction)
>
> PortableRemoteObject.narrow(initialContext.lookup("javax.transaction.UserTra
> nsaction"),
> UserTransaction.class);
> } catch (Exception e) {
> System.err.println("Cannot lookup UserTransaction: "+e);
> System.exit(2);
> }
> // OpBean creation
> Op t1 = null;
> try {
> System.out.println("Create a bean");
> t1 = home.create("User1");
> } catch (Exception e) {
> System.err.println("Cannot create OpBean: " + e);
> System.exit(2);
> }
> // Start another transaction (rolled back)
> try {
> System.out.println("Start a second transaction");
> utx.begin();
> t1.buy(50);
> System.out.println("Rollback the transaction");
> utx.rollback();
> } catch (Exception e) {
> System.err.println("exception during 2nd Tx: " + e);
> System.exit(2);
> }
>
> When the t1.buy() method is called, a new UserTransaction object is created
> instead of using the already existing transaction. Then, when I try to
> invoke rollback(), it doesn't work.
> The only output I got is: "Bad value read: 80"
>
> Am I doing something wrong? Or is it a 2.2.2 problem?
>
> Thanks in advance,
> ...fernando
Hi Fernando,
the only difference that I see in your code is that you specify the
transactional
attribute to Required only to the method buy. In our sample it is
specified
to Required for all the methods of the beans
<method-name>*</method-name>
But if you run the clientOp this makes no difference at all.
The meaning of this attributes is not that the container "should create
a UserTransaction object"
it means that if a business method of the bean is called with no
transaction
the container will initiate a transaction before invoking the business
method
and commit it after. If the bean is called inside a transaction scope
(the transaction
has been initiated by the the client) nothing is done.
UserTransaction Object are objects used by a client or bean with bean
managed transaction.
Your code and our seems similar so it does work. The sample sb works
with JOnAS 2.2.2.
perhaps there have you made other changes?
regards,
--
Philippe
Philippe Coq Evidian Phone: (33) 04 76 29 78 49
Bull S.A - 1 rue de Provence - 38432 Echirolles Cedex France
Download our EJBServer at http://www.objectweb.org
----
To unsubscribe, send email to [EMAIL PROTECTED] and
include in the body of the message "unsubscribe jonas-users".
For general help, send email to [EMAIL PROTECTED] and
include in the body of the message "help".