最简单的Hello
1.定义一个接口
public interface FirstEjb {
public String saySomthing(String name);
}
2.实现定义的接口
@Stateless
@Remote
public class FirstEjbBean implements FirstEjb {
public String saySomthing(String name) {
// TODO Auto-generated method stub
return "你好," + name;
}
}
3.Client.java
public class FirstEjbClient {
public static void main(String[] args) throws Exception {
Properties props = new Properties();
props.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
props.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
props.put("java.naming.provider.url", "localhost");
InitialContext context = new InitialContext(props);
//FirstEjb firstEjb = (FirstEjb)context.lookup("FirstEjbBean/remote");
//System.out.println(firstEjb.saySomthing("刘瑞超"));
}
}