一个紧急的问题(各位请进 进者有分)

Teddy5858 2003-09-15 10:24:30
以下两个方法是SESSION BEAN 下的( 远程接口)

public java.lang.Integer funFind(String name) {
this.name=name;
try{
InitialContext ctx=new InitialContext();
Object ref = ctx.lookup("Account");//错误在此
AccountHome home = (AccountHome)ref;
try{
Account account=home.findByPrimaryKey(name);
result=account.getBalance();
return result;
}
catch(Exception ex){
System.out.println("Find Error:"+ex.getMessage());
}
}
catch(Exception ex){
throw new EJBException("Unable To Connection To Database :"+ex.getMessage());
}
return null;
}

public String funMessage(){
return "TEST OK!";
}

测试程序去调用 funMessage() 方法成功。
但是去调用funFind("teddy") 方法失败。
Object ref = ctx.lookup("Account");//错误在此
AccountHome home = (AccountHome)ref;

Account是一个ENTITY BEAN ( 本地接口 )
环境:JBUILDER 9, INTERBASE, Borland Enterprise Server 5.2
请问如何解决?
MSN/EMAIL:CHENHAIJUN5858@163.COM
...全文
47 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
Teddy5858 2003-09-15
  • 打赏
  • 举报
回复

AccountHome home = (AccountHome)ref;
改为
AccountHome home=(AccountHome) PortableRemoteObject.narrow(ref,AccountHome.class);
在部署时出现警告信息:

Generating stubs for ACCOUNT.ear
Compiling 65 files (using javac)
Stubs successfully generated
Merging archive contents: _bes_stubs.jar
Merging archive contents: ACCOUNT
Verifying C:\BES\tmp\console\tmpbes_23325\ACCOUNT.ear
Verifying application module ACCOUNT.ear [role=deployer]
...verifying ejb module ACCOUNTEJB.jar in ACCOUNT.ear
#### Warning: [ACCOUNTEJB.jar] Session Bean "SesAccount"
Static fields in the bean class must be final:
static java.lang.Class com.borland.ejb.SesAccountBean.class$com$borland$ejb$AccountHome
#### Warning: [ACCOUNTEJB.jar] Session Bean "SesCountry"
Static fields in the bean class must be final:
static java.lang.Class com.borland.ejb.SesCountryBean.class$com$borland$ejb$CountryHome
...verifying web module ACCOUNTWEB.war in ACCOUNT.ear
...verifying library module WEB-INF/lib/interclient.jar in ACCOUNTWEB.war in ACCOUNT.ear
...verifying library module WEB-INF/lib/struts.jar in ACCOUNTWEB.war in ACCOUNT.ear
...verifying jndi definitions module META-INF/jndi-definitions.xml in ACCOUNT.ear
...verifying library module _bes_stubs.jar in ACCOUNT.ear
0 errors, 2 warnings
Deploying modules to partition standard
Deploying ACCOUNT to bes://teddy/standard
Enabling modules in partition standard
Deployment completed

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧