我是 EJB 新手,正在尝试“Hello World”类型的 EJB Java 程序。这是我的 EJB:
package dukesbookstore.ejb;
@Stateless(name="BookRequestBean", mappedName="ejb/BookRequestBean")
@Named
public class BookRequestBean {
//Other codes here
}
这是我的客户:
Properties prop = new Properties();
prop.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.enterprise.naming.SerialInitContextFactory");
prop.setProperty("org.omg.CORBA.ORBInitialHost", "localhost");
prop.setProperty("org.omg.CORBA.ORBInitialPort", "3700");
try {
InitialContext ctx = new InitialContext(prop);
ctx.lookup("ejb/BookRequestBean");
System.out.println("EJB Look-up successfull!!");
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
但是每当我尝试运行时,我都会遇到以下异常:
javax.naming.NamingException:在 SerialContext [myEnv={org.omg.CORBA.ORBInitialPort=3700,java.naming.factory.initial=com.sun.enterprise.naming.SerialInitContextFactory,org. omg.CORBA.ORBInitialHost=本地主机,java
我添加了appserv-rt.jar
, gf-client.jar
, javaee.jar
,但仍然没有运气。谁能帮助我,我在这里缺少什么?我是使用 Glassfish 3.1