1:先安装weblogic11g 我安装在C:\Oracle\Middleware
2:新建一个域
开始菜单---》Configuration wizard--->接着就按照下面的图解一步步实现即可!







接下来 打开myeclipse ---> window--->preferences-->myeclipse enterprice workbench - servers -->weblogic10g 按照下面的图填写即可
用户名和密码 就是创建域的时候输入的用户名和密码!

接下来就开始写代码了!
首先新建一个ejbproject
步骤:
1:菜单new -->ejbproject(命名为testejb如下图)

2:选择testejb项目右击new--->ejb3 sessionbean(如下图)

3:则自动生成如下两个代码:
package cn.ljz.test; import javax.ejb.Stateless; @Stateless(mappedName="helloWorld") public class HelloWorldBean implements HelloWorldBeanRemote { public String sayHelloWorld() { return "Hello Ejb"; } }
package cn.ljz.test; import javax.ejb.Remote; @Remote public interface HelloWorldBeanRemote { String sayHelloWorld(); }
最后点击

部署ejb组件
打开C:\Oracle\Middleware\user_projects\domains\base_domain\autodeploy
查看ejb是否部署成功!
或者打开http://localhost:7001/console
输入刚才创建域的用户名和密码查看是否部署成功!(如下图)

最后写一个测试类
package cn.ljz.test;
import java.util.Properties;
import javax.naming.*;
public class Client {
public static void main(String[] args) {
Properties props = new Properties();
props.setProperty(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
props.setProperty(Context.PROVIDER_URL,"t3://localhost:7001");
try {
InitialContext ctx = new InitialContext(props);
HelloWorldBeanRemote myHello = (HelloWorldBeanRemote) ctx.lookup("helloWorld#cn.ljz.test.HelloWorldBeanRemote");
System.out.println(myHello.sayHelloWorld());
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
测试结果为:(对了 别忘了导入C:\Oracle\Middleware\wlserver_10.3\server\lib里面的weblogic.jar文件)
