EJB

package com.erik;

import java.util.Properties;

import javax.naming.InitialContext;
import javax.naming.NamingException;

public class HelloWorldClient {
public static void main(String[] args) {
try {
Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
"org.jnp.interfaces.NamingContextFactory");
props.setProperty("java.naming.provider.url", "localhost:1099");
props.setProperty("java.naming.factory.url.pkgs",
"org.jboss.naming");

System.out.println(">>>> InitialContext ");
InitialContext ctx = new InitialContext(props);
System.out.println(">>>> lookup  ");
String jndiName = "HelloWorld/remote";
HelloWorldRemote helloWorld = (HelloWorldRemote) ctx
.lookup(jndiName);
System.out.println(">>>> 调用sayHello(\"micmiu.com\")");
String result = helloWorld.sayHello("micmiu.com");
System.out.println(">>>> 结果 = " + result);
} catch (NamingException e) {
e.printStackTrace();
}
}
}

你可能感兴趣的:(ejb)