I can not obtain a UserTransaction object from a remote computer
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Yonghua_Zhai
Posted On:   Monday, March 19, 2001 05:38 AM

This question is not answered by "How does a client application create a transaction object?" I'm running Sun's J2ee server on one machine(csutest), and from another machine, I could do a lookup and find a reference to the remote EJBs, but I failed to lookup the UserTransaction object because I got a CommunicationException( Can't find SerialContextProvider). By the way, I could get UserTransaction if I run my client program on the same machine as the J2EE server. I set up Context.INITIAL_CONTEXT_FACTORY and Context.PROVIDER_URL correctly, otherwise I would be able to look up EJBs. The following is my code sinppet: // my J2EE server is running on csutest:1050 Properties env = Sys   More>>

This question is not answered by "How does a client application create a transaction object?"

I'm running Sun's J2ee server on one machine(csutest), and from another machine, I could do a lookup and find a reference to the remote EJBs, but I failed to lookup the UserTransaction object because I got a CommunicationException( Can't find SerialContextProvider). By the way, I could get UserTransaction if I run my client program on the same machine as the J2EE server. I set up
Context.INITIAL_CONTEXT_FACTORY and
Context.PROVIDER_URL correctly, otherwise I would be able to look up EJBs.




The following is my code sinppet:

// my J2EE server is running on csutest:1050
Properties env = System.getProperties();
env.put
(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.C NCtxFactory");
env.put(Context.PROVIDER_URL, "iiop://csutest:1050");
env.put("org.omg.CORBA.ORBInitialHost", "csutest:1050");
Context ctx = new InitialContext(env);

// OK running on local or remote
Object objref = ctx.lookup("LOGManager"); // LOGManager is the lookup name of a Session EJB


// got exception if running from remote machine, OK if running on the same machine as the J2EE server
UserTransaction utx = (UserTransaction) ctx.lookup ("java:comp/UserTransaction");



The exception looks like the following:
javax.naming.CommunicationException: Can't find SerialContextProvider at
com.sun.enterprise.naming.SerialContext.getProvider (SerialContext.java:60)
at com.sun.enterprise.naming.SerialContext.
(SerialContext.java:79)
at com.sun.enterprise.naming.SerialContext.
(SerialContext.java:89)
at
com.sun.enterprise.naming.java.javaURLContext.getComponentContext (javaURLContext.java:397)
at com.sun.enterprise.naming.java.javaURLContext.lookup (javaURLContext.java:51)
at javax.naming.InitialContext.lookup(Unknown Source)
at
ca.cgi.ajc.rms.LogMng_WB.validateLoginLogMng_WB.java:182)


Thank you very much.

   <<Less

Help! JSP call EJB on another machine using JNDI

Posted By:   Brooks_Chin  
Posted On:   Wednesday, March 21, 2001 03:43 PM

Hi,
I tried to invoke ejb through a JSP/Java Bean using the JNDI lookup.
When my ejb and JSP/Java Bean are running on the same machine it worked fine.
But I had to deploy ejb and JSP/Java Bean on different machines. What is correct way?
My try: (The Java 2 Enterprise Edition Developer's Guid, chapter 7, JSP sample code)
Both machine run J2EE server, NT system.
1. deploy successful ejb.jar on 1st machine
Copy ejb.jar file to the 2nd machine.
creat and deploy web.war file on the 2nd machine.
In the Bean,
java.util.Properties p = new java.util.Properties();

p.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); //right?
//p.put(javax.naming.Context.PROVIDER_URL,"iiop://localhost:1099"); //right??
p.put(javax.naming.Context.PROVIDER_URL,"iiop://NH24802:1050");

Context ic = new InitialContext(p);

java.lang.Object objref = ic.lookup("java:comp/env/ejb/Account");

accountHome = (AccountHome) PortableRemoteObject.narrow(objref,
AccountHome.class);
account = accountHome.create(id, firstName, lastName, balance);
About | Sitemap | Contact