With some search, it seems that you do need to provide the ejb
container info by
1, providing a jndi.properties in your client classpath with following content:
java.naming.factory.initial=org.openejb.client.RemoteInitialContextFactory
java.naming.provider.url=ejb_container_ip:4201
java.naming.security.principal=system
java.naming.security.credentials=manager
or
2, using following code to create the initial context in your client code.
Properties env = new Properties();
env.put("java.naming.factory.initial","org.apache.openejb.client.RemoteInitialContextFactory");
env.put("java.naming.factory.host", "ejb_container_ip");
env.put("java.naming.factory.port", "4201");
env.put("java.naming.security.principal", "system");
env.put("java.naming.security.credentials", "manager");
ctx = new InitialContext(env);
hope it helps.
2008/12/28 axiez <[email protected]>:
>
> I want to run sample code to understand ejb 3.0 basics. I am new to ejb. I
> have the following java files: ShoppingCartBean.java, ShoppingCart.java and
> Client.java. The Client.java file has the following code:
> import javax.naming.InitialContext;
> public class Client {
> public static void main(String[] args) throws Exception {
> InitialContext ctx = new InitialContext();
> ShoppingCart cart = (ShoppingCart)
> ctx.lookup("ShoppingCartBean/remote");
> ...
> }
> My plan is to have client on a different JVM than ejb container. I
> wonder how the client can execute bean method without even knowing IP
> address etc of the JVM that has the other code on ejb container.
> --
> View this message in context:
> http://www.nabble.com/ejb-client-tp21193112s134p21193112.html
> Sent from the Apache Geronimo - Users mailing list archive at Nabble.com.
>
>
--
Shawn