How can I get UserTransaction from a EJB Client?
843853Jul 31 2001 — edited Mar 15 2005Hi
Anyone can tell me what is the correct way to get the UserTransaction from a EJB Client? I've tried the following code in JBoss, but it gives "javax.naming.NameNotFoundException: comp not bound" error:
Properties env = new Properties();
env.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
env.setProperty("java.naming.provider.url", "localhost:1099");
Context ctx = new InitialContext(env);
UserTransaction ut = (UserTransaction)ctx.lookup("java:comp/UserTransaction");
I've read through this news group and found quite a number of people is facing the same problem. Are there any experts to give some explanation?
Also someone has said that it is not a good practice to manage the transaction at the EJB client level. But it is quite common that my client needs to involves EJB1.operation1() and EJB2.operation2(), and I want to put them into a transaction. So what is the correct way to handle this situation?
Best Regards,
Rongan