View the original post : 
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3820748#3820748

Reply to the post : 
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3820748

Hi,



I am trying to use container managed transactions but only bean-managed work.

I am using Jboss 3.2.1 with Jetty. I do not have any entity beans. I have a connection 
that i got from a DataSource in a session bean which calls various methods.



Pseudo-code (includes bean-managed things i commented out -- my goal is to make them 
go away):







//javax.transaction.UserTransaction ut = sessionContext.getUserTransaction();

    Connection connx = null;



try {

// ut.begin();



connx = getDataConnection (DEFAULT_DB);

 // connx.setAutoCommit(false);



sqlInsertOne( connx );



if (true) throw new NullPointerException("transaction roll back, darn it!");



sqlInsertAnotherOne( connx );



//      ut.commit();

//  connx.commit();



} catch (Exception e) {

  //    connx.rollback ();

//      ut.rollback();

 throw e;

}





The goal is to made the first statement, sqlInsertOne(), not happen when the second 
statement (or I) throws an exception. 



If i use bean-managed transactions and *iether* the transactions provided by 
UserTransaction, or just the commit() and rollback() provided by the Connection, then 
it is fine. My exception gets thrown and sqlInsertOne() does not happen.



But the second i try to use Container managed transactions, everything goes awry. 
sqlInserOne() inserts! how do i make it stop? am i missing a configuration file? are 
session beans meant to manage transactions?



I change ejb-jar.xml. To make it container managed i have



 <session-type>Stateless</session-type>

            <transaction-type>Container</transaction-type>



and 



<container-transaction> 

< method >  

<ejb-name>TradeEngine</ejb-name>

<method-name>*</method-name>

</ method >

<trans-attribute>Required</trans-attribute>

</container-transaction>



am i supposed to edit some other config file besides ejb-jar.xml?



thanks to anyone who can help.


-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to