您的位置:首页 > 其它

创建ejb项目以及weblogic部署ejb

2016-11-15 13:39 417 查看
1.创建ejb项目

2.通过注解声明ejb接口

接口

@Remote(value=FirstEjbBean.class)

public interface FirstEjb {

public String GetUserName(String g);

}

实现类

@Stateless(mappedName = "FirstEjbBean")

public class FirstEjbBean implements FirstEjb {

public String GetUserName(String g) {

// TODO Auto-generated method stub

return g+"******";

}

}

3.ejb项目打包成jar,weblogic部署,weblogic的域端口为1099

一直下一步即可。

4.客户端代码

lookup 的查看:

lookup("mappedName的值#接口的完整包和类");

客户端需要引入ejb接口包。

把ejb项目中接口的类打成jar包,客户端引入即可。

Properties properties=new Properties();

properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");

properties.setProperty(Context.PROVIDER_URL,"t3://localhost:1099");

Context ctx = new InitialContext(properties);

FirstEjb fejb= (FirstEjb)ctx.lookup("FirstEjbBean#com.fos.FirstEjb");

System.out.println(fejb.GetUserName("555555"));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ejb weblogic