This content has been marked as final.
Show 4 replies
-
1. Re: UserTransaction and Servlets
sesques Apr 20, 2004 7:43 AM (in response to jurban)You must use a user transaction created in your servlet, and configure all your beans with transaction type set to "required".
Code for your servlet:try{ ctx = new InitialContext(); tx = (UserTransaction)ctx.lookup("UserTransaction"); tx.begin(); ... //Do what you want with your beans ... tx.commit(); } catch (Exception e) { tx.rollback(); } finally { ctx.close(); }
Since the Arjuna integration onto JBoss, I think that JBoss supports Natively JTS (which is not part of EJB spec) without specific configuration.
Hope this helps you -
2. Re: UserTransaction and Servlets
jurban Apr 20, 2004 9:01 AM (in response to jurban)"sesques" wrote:
Code for your servlet:try{ ctx = new InitialContext(); tx = (UserTransaction)ctx.lookup("UserTransaction");
I tried this and received the following Exception:
javax.naming.NameNotFoundException: Name UserTransaction is not bound in this Context -
3. Re: UserTransaction and Servlets
sesques Apr 20, 2004 9:33 AM (in response to jurban)Of course, I'm silly.
You cannot initiate a JBoss UserTransaction because your servlet is running in a standalone tomcat instance, which is the web container. The user transaction is part of EJB container only.
It depends on how your Tomcat is configured. Does it have a JTS library ?
Also, the UserTransaction JNDI name should be name "java:comp/
env/UserTransaction" or something like that.
I confess that I don't know this config, so I cannot help you anymore.
Good luck -
4. Re: UserTransaction and Servlets
jurban Apr 20, 2004 3:06 PM (in response to jurban)Does it have a JTS library
It's a stock Tomcat install. What jar file should I search for to see if JTS is installed?
Thanks,
Jim