Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I get UserTransaction from a EJB Client?

843853Jul 31 2001 — edited Mar 15 2005
Hi
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 12 2005
Added on Jul 31 2001
7 comments
412 views