Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

client-intiated transactions

 
siva sankar
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi vinay,

thanks for your reply.I tried by placing the line you suggested.But i am getting the same error.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic