当前位置: 技术问答>java相关
请教一个EJB问题
来源: 互联网 发布时间:2015-06-05
本文导语: 我在JBuilder5和Borland AppServer4.5.1的环境下学习EJB。编了一个简单的实体bean(Teller)。在本机上配置bean并运行测试客户端程序是可以的。但是当我在另一台机器上(也有JBuilder5和Borland AppServer4.5.1)配置了Teller bean,本...
我在JBuilder5和Borland AppServer4.5.1的环境下学习EJB。编了一个简单的实体bean(Teller)。在本机上配置bean并运行测试客户端程序是可以的。但是当我在另一台机器上(也有JBuilder5和Borland AppServer4.5.1)配置了Teller bean,本机上将bean从BAS上关闭,只留下客户端程序之后,从我的本机上就无法使用远程的bean了,具体情况如下:
这是我的客户端测试程序的代码片段:
Context ctx = new InitialContext();
Object ref = ctx.lookup("Teller");
tellerHome = (TellerHome) PortableRemoteObject.narrow(ref, TellerHome.class);
以下是出错时的提示信息:
-- Failed initializing bean access.
javax.naming.NameNotFoundException. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:34)
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.extract(NotFoundHelper.java:50)
at org.omg.CosNaming._NamingContextStub.resolve(_NamingContextStub.java:161)
at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:324)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:373)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:351)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at quickstart.Client.(Client.java:35)
at quickstart.Client.main(Client.java:153)
后来我尝试将代码改变如下:
Context ctx = new InitialContext();
Object ref = ctx.lookup("java:comp/env/ejb/Teller");
tellerHome = (TellerHome) PortableRemoteObject.narrow(ref, TellerHome.class);
就出现如下的错误提示信息:
-- Failed initializing bean access.
javax.naming.NameNotFoundException: Missing Node - Teller
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:511)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:521)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:521)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:521)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:521)
at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:974)
at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:979)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at quickstart.Client.(Client.java:35)
at quickstart.Client.main(Client.java:153)
请各位高手指点一二!不胜感谢!对了,我是初到此处,不知该如何给分,也请告知!
这是我的客户端测试程序的代码片段:
Context ctx = new InitialContext();
Object ref = ctx.lookup("Teller");
tellerHome = (TellerHome) PortableRemoteObject.narrow(ref, TellerHome.class);
以下是出错时的提示信息:
-- Failed initializing bean access.
javax.naming.NameNotFoundException. Root exception is org.omg.CosNaming.NamingContextPackage.NotFound
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.read(NotFoundHelper.java:34)
at org.omg.CosNaming.NamingContextPackage.NotFoundHelper.extract(NotFoundHelper.java:50)
at org.omg.CosNaming._NamingContextStub.resolve(_NamingContextStub.java:161)
at com.sun.jndi.cosnaming.CNCtx.callResolve(CNCtx.java:324)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:373)
at com.sun.jndi.cosnaming.CNCtx.lookup(CNCtx.java:351)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at quickstart.Client.(Client.java:35)
at quickstart.Client.main(Client.java:153)
后来我尝试将代码改变如下:
Context ctx = new InitialContext();
Object ref = ctx.lookup("java:comp/env/ejb/Teller");
tellerHome = (TellerHome) PortableRemoteObject.narrow(ref, TellerHome.class);
就出现如下的错误提示信息:
-- Failed initializing bean access.
javax.naming.NameNotFoundException: Missing Node - Teller
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:511)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:521)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:521)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:521)
at com.inprise.j2ee.jndi.java.javaContext.internal_lookup(javaContext.java:521)
at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:974)
at com.inprise.j2ee.jndi.java.javaContext.lookup(javaContext.java:979)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at quickstart.Client.(Client.java:35)
at quickstart.Client.main(Client.java:153)
请各位高手指点一二!不胜感谢!对了,我是初到此处,不知该如何给分,也请告知!
|
Context ctx = new InitialContext();
这句有问题啦!每种APP SERVER得到Context的方法是不一样的! hexiaofeng(java爱好者)他告诉你的是weblogic环境下的方法,而appserver肯定不是这样,你可以看看APPSERVER的帮助啦!
这句有问题啦!每种APP SERVER得到Context的方法是不一样的! hexiaofeng(java爱好者)他告诉你的是weblogic环境下的方法,而appserver肯定不是这样,你可以看看APPSERVER的帮助啦!
|
应该有一个方法
private Context getInitialContext() throws Exception {
String url = "t3://localhost:7001";
将url改变就应该可以了,我用的是weblogic。。
给分 。。。。点击帖子 后面的管理即可
private Context getInitialContext() throws Exception {
String url = "t3://localhost:7001";
将url改变就应该可以了,我用的是weblogic。。
给分 。。。。点击帖子 后面的管理即可