This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes client-intiated  transactions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "client-intiated  transactions" Watch "client-intiated  transactions" New topic
Author

client-intiated transactions

siva sankar
Ranch Hand

Joined: Jul 13, 2006
Posts: 68
Hi,

I am using jboss 3.2.5.when i am trying to invoke the bussiness method defined in the ejb from a standalone application using javax.transaction.UserTransaction, i am getting the following exception:

javax.transaction.SystemException: java.lang.RuntimeException: UT factory lookup failed: javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial


Here is my code

/* Shows how to control transactions from client
Author : Team -J
Version : 1.0 , with this example we set transaction attribute
to mandatory
*/



import cmt.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.*;

public class CMTransClient {

public static void main(String[] args) {
Hashtable ht=new Hashtable();

try {
ht.put(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingContextFactory");
System.out.println("hello");
ht.put(Context.PROVIDER_URL,"jnp://localhost:8080:1099");
System.out.println("hello");
ht.put("java.naming.factory.url.pkgs","org.jboss.naming rg.jnp.interfaces");
System.out.println("hello");
Context ic=new InitialContext(ht);
cmt.CMTransHome home =(cmt.CMTransHome)ic.lookup("cmt.CMTransHome");
cmt.CMTransRemote h = home.create();
javax.transaction.UserTransaction ut = (javax.transaction.UserTransaction)ic.lookup("UserTransaction");
System.out.println("Transaction object = "+ ut.getClass());
if (ut == null)
System.out.println("ut is null");
else
System.out.println("ut is not null");

ut.begin();
h.PerformSomeDBOperation(1000);
ut.commit();
//un comment below line and check !!!
// ut.rollback();
}catch(Exception e){ System.out.println(e);}
}


}

please suggest me a solution on how to resolve this issue.where exactly we can find or configure the jndi name for javax.transaction.UserTransaction.


Thanks in Advance,
regards,
Siva Sankar
Vinay Raj
Ranch Hand

Joined: Jun 19, 2006
Posts: 81
Is the following line correct?

ht.put(Context.PROVIDER_URL,"jnp://localhost:8080:1099");

I believe it should be

ht.put(Context.PROVIDER_URL,"jnp://localhost:1099");
siva sankar
Ranch Hand

Joined: Jul 13, 2006
Posts: 68
Hi vinay,

thanks for your reply.I tried by placing the line you suggested.But i am getting the same error.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: client-intiated transactions
 
Similar Threads
JTA Problem--The Xid is not valid
JNDI Name in EJB3
Sorting Vector of Hashtables by a Hashtable value
Context Lookup Failing
Getting Error while runnning Session Bean Client