各位GGJJDDMM帮帮忙,实现一个简单的EJB!!!

santld 2004-02-07 08:16:48

我刚刚学习EJB,用的环境是JBuilder9+Weblogic8.1
环境已经配置好了,在JB中可以正常启动Weblogic Server
以下是步骤:
1.新建一个项目
2.创建一个EJB2.0
3.添加代码:
====== Hello.java ====================
package helloworld;

import javax.ejb.*;
import java.util.*;
import java.rmi.*;

public interface Hello extends javax.ejb.EJBObject {
public java.lang.String getHello()throws java.rmi.RemoteException;
}

====== HelloBean.java =================
package helloworld;
import javax.ejb.*;

public class HelloBean implements SessionBean {
SessionContext sessionContext;
public void ejbCreate() throws CreateException {}
public void ejbRemove() {}
public void ejbActivate() {}
public void ejbPassivate() {}
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
}
/* 商务方法
*/
public java.lang.String getHello() {
/**@todo Complete this method*/
return "hello world!!!";
}
}

========== HelloHome.java ========================
package helloworld;

import javax.ejb.*;
import java.util.*;
import java.rmi.*;

public interface HelloHome extends javax.ejb.EJBHome {
public Hello create() throws CreateException, RemoteException;
}


然后建立了一个测试类,只在main函数里加了几句
============== HelloTestClient1.java =================
...
public static void main(String[] args) {
String ss = "";
HelloTestClient1 client = new HelloTestClient1();
try{
Hello he = client.getHome().create();
ss = he.getHello();
System.out.println(ss);
he.remove();
}catch(Exception e){}
}
...
然后启动weblogic server,运行测试类,可是总不成功,错误如下:
javax.naming.NameNotFoundException: Unable to resolve 'Hello' Resolved ; remaining name 'Hello'

at weblogic.rjvm.BasicOutboundRequest.sendReceive(BasicOutboundRequest.java:108)

at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:284)

at weblogic.rmi.cluster.ReplicaAwareRemoteRef.invoke(ReplicaAwareRemoteRef.java:244)

at weblogic.jndi.internal.ServerNamingNode_812_WLStub.lookup(Unknown Source)

at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:343)

at weblogic.jndi.internal.WLContextImpl.lookup(WLContextImpl.java:336)

at javax.naming.InitialContext.lookup(InitialContext.java:347)

at helloworld.HelloTestClient1.initialize(HelloTestClient1.java:22)

at helloworld.HelloTestClient1.<init>(HelloTestClient1.java:13)

at helloworld.HelloTestClient1.main(HelloTestClient1.java:65)

Caused by: javax.naming.NameNotFoundException: Unable to resolve 'Hello' Resolved

at weblogic.jndi.internal.BasicNamingNode.newNameNotFoundException(BasicNamingNode.java:858)

at weblogic.jndi.internal.BasicNamingNode.lookupHere(BasicNamingNode.java:230)

at weblogic.jndi.internal.ServerNamingNode.lookupHere(ServerNamingNode.java:154)

at weblogic.jndi.internal.BasicNamingNode.lookup(BasicNamingNode.java:188)

at weblogic.jndi.internal.RootNamingNode_WLSkel.invoke(Unknown Source)

at weblogic.rmi.internal.BasicServerRef.invoke(BasicServerRef.java:477)

at weblogic.rmi.cluster.ReplicaAwareServerRef.invoke(ReplicaAwareServerRef.java:108)

at weblogic.rmi.internal.BasicServerRef$1.run(BasicServerRef.java:420)

at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:353)

at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:144)

at weblogic.rmi.internal.BasicServerRef.handleRequest(BasicServerRef.java:415)

at weblogic.rmi.internal.BasicExecuteRequest.execute(BasicExecuteRequest.java:30)

at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)

at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)

各位帮帮我啊,急死我了!!
...全文
5 点赞 收藏 9
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复

还没有回复,快来抢沙发~

发帖
Java EE
创建于2007-09-28

6.6w+

社区成员

J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
申请成为版主
帖子事件
创建了帖子
2004-02-07 08:16
社区公告
暂无公告