I wrote my first EJB and got it successfully deployed in the j2ee Server(accompanying sun's j2ee kit).I also wrote the client side code for the same and the client side code is like this:
import javax.naming.*;
import java.util.*;
import javax.rmi.PortableRemoteObject;
public class HelloClient
{
public static void main(String args[]) throws Exception
{
Context cxt = new InitialContext();
Object obj = cxt.lookup("HelloWorldApp");
HelloHome home = (HelloHome)
javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);
Hello hello = home.create();
System.out.println(hello.hello());
hello.remove();
}
}
HelloWorldApp is the JNDI Reference name I entered in the process of deployment and i receive an exception stating that it is unable to identify the Provider name.
What's to be done.
Mathi Ezhil
-
First EJB Hello World (3 messages)
- Posted by: mathi ezhil
- Posted on: September 03 2002 09:10 EDT
Threaded Messages (3)
- First EJB Hello World by Ahmed Talaat on September 03 2002 09:26 EDT
- First EJB Hello World by mathi ezhil on September 03 2002 09:35 EDT
- First EJB Hello World by Ahmed Talaat on September 03 2002 09:58 EDT
- First EJB Hello World by mathi ezhil on September 03 2002 09:35 EDT
-
First EJB Hello World[ Go to top ]
- Posted by: Ahmed Talaat
- Posted on: September 03 2002 09:26 EDT
- in response to mathi ezhil
Your client is running outside of the server contexts so instantiating a new Context like that won't work.
you need to use as a hastable, set the Context.INITIAL_CONTEXT_PROVIDER and Context.PROVIDER_URL and then instantiate the Context passing the hashtable.
With Weblogic this would look like this :
-------------------------------------
Hashtable env = new Hashtable (3);
env.put (InitialContext.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
env.put (InitialContext.PROVIDER_URL, "t3://localhost:7001");
ctx = new InitialContext (env);
----------------------------------------
Hope this helps. -
First EJB Hello World[ Go to top ]
- Posted by: mathi ezhil
- Posted on: September 03 2002 09:35 EDT
- in response to Ahmed Talaat
As per my earlier posting regarding the helloWorld EJB,i knew the environment variables for weblogic.I need to know the same for the defalut J2EE server provided by sun along with j2ee kit -
First EJB Hello World[ Go to top ]
- Posted by: Ahmed Talaat
- Posted on: September 03 2002 09:58 EDT
- in response to mathi ezhil
hmmm, I didn't get that impression from your earlier post :-)
anyway, I beleive this is what you are looking for :
----------------------------------
props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
props.put(Context.PROVIDER_URL, "iiop://localhost:1050");
----------------------------------
let me know if it works, I never worked with the sun toolkit before :-)
Cheers,