再问一entityBean的问题。解决后马上结账。 客户端调用实体bean的指针为空,可能因为你没有在客户端执行create()或bean本身有错误 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你有没有在服务器端的EJB编写的时候加入异常操作啊,另外就是Bean不能使用线程或者线程API 谢谢大家,客户端代码如下:private void myInit() throws Exception { 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的方法。} to blueye11(流浪的我) ,加入了异常操作代码的。还有,我就是在SessionBean中调用EntityBean的findByPrimaryKey()也是如此。 SessionBean中的关键代码如下: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的名字,这样写对不对啊。请各位大侠赐教。 楼上的兄弟,要是输出结果为: aacc我才能完全相信你说的话,应该是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"); 权限表设计 求一个成熟的SSH+EXT框架,保证不照搬,只是参照 hibernate 中flush 动态生成tree jpa in spring 的事务传播 怎样在JBoss里面配置JMS的连接工厂? struts中页面转向出现IllegalStateException,求教!! 请问条马扫描接口编程怎么搞! 本人准备学习j2ee,请各位推荐一本这方面的好书 Java中常用英语 为什么我安装了 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");