客户端调用实体bean的指针为空,可能因为你没有在客户端执行create()或bean本身有错误
解决方案 »
- 谁有3年以上的Java开发经验
- ssh问题
- Javamail读取邮件正文的问题
- 开发一套象SoGou地图这样的系统大概需要多少钱?
- 初学webwork,请高手引进入门!!
- 如何在javascript打开url,传中文,然后在jsp中正常接收中文?
- 求 代码生成工具,500分相送!在此先贴100,望各位帮忙!
- 有人用过myejb吗,在哪可以找到这方面的资9料
- 关于j2ee和j2me的前景,有建议就给分!
- 如果不使用web.xml文件,在学习struts2时怎么配置filter?
- 为什么我安装了 j2ee sdk 1.3.1,J2ee.jar已经配置好了, 仍然不能用 import javax.ejb.ejbObject 为什么?
- lomboz相关
try {
Context context=new InitialContext();
home=(SessionStudentHome)PortableRemoteObject.narrow(context.lookup("SessionStudent"),SessionStudentHome.class);
session=(SessionStudent)home.create();
}
catch (Exception ex) {
ex.printStackTrace();
} try{
jTModel.addColumn("学号");
jTModel.addColumn("姓名");
jTModel.addColumn("班级");
session=(SessionStudent)home.create();
ArrayList alt=session.findStudentC();//执行到此处出错,些方法为SessionBean中调用EntityBean的方法。
}
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
try{
Context context = new InitialContext();
System.out.println("aa");
this.studenthome=(StudentHome)context.lookup("java:comp/env/ejb/Student");
System.out.println("bb");
}
catch (Exception ex) {
System.out.println("cc");
throw new EJBException(ex);
}
}结果是输出cc,看来是 this.studenthome=(StudentHome)context.lookup("java:comp/env/ejb/Student");这句没通过,其中Student是实体Bean的名字,这样写对不对啊。请各位大侠赐教。
aa
cc
我才能完全相信你说的话,应该是
this.studenthome=(StudentHome)context.lookup("java:comp/env/ejb/Student");
出错了。但是我想你能否告诉我你的entitybean是否为local接口的?
要是的话,我看这样可否:
Context context = new InitialContext();
System.out.println("aa");
this.studentHome = (Student)context.lookup("Student");
System.out.println("bb");