Java开发网 |
注册 |
登录 |
帮助 |
搜索 |
排行榜 |
发帖统计
|
您没有登录 |
» Java开发网 » Java EE 综合讨论区
打印话题 寄给朋友 订阅主题 |
作者 | DAO模式下连接sessionBean出错??求教 |
neweagle
发贴: 2 积分: 0 |
于 2004-06-28 17:08
有问题请教各位大侠 我用的jbuilder9+weblogic8 在用DAO模式设计EJB时出现下面错误: ejbtest.dao.BookDAOSysException: BookDAOFactory.getDAO: NamingException while getting DAO type: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial at ejbtest.dao.BookDAOSessionBeanFactory.getDAO(BookDAOSessionBeanFactory.java:23) at ejbtest.javaben.TestDao.<init>(TestDao.java:29) at ejbtest.javaben.TestDao.main(TestDao.java:81) java.lang.NullPointerException at ejbtest.javaben.TestDao.getAll(TestDao.java:39) at ejbtest.javaben.TestDao.main(TestDao.java:83) java.lang.Exception: failure:null at ejbtest.javaben.TestDao.getAll(TestDao.java:42) at ejbtest.javaben.TestDao.main(TestDao.java:83) BookDAOSessionBeanFactory.java: import javax.naming.InitialContext; import javax.naming.NamingException; import java.util.Properties; import javax.naming.Context; /***/ public class BookDAOSessionBeanFactory { public static String Book_DAO_CLASS="java:comp/env/param/BookDAOClass"; public BookDAOSessionBeanFactory() { } public static BookDAO getDAO() throws BookDAOSysException{ BookDAO bookDAO=null; try{ //this connect sessionbean InitialContext context = new InitialContext(); String className = (String)context.lookup(Book_DAO_CLASS);//"java:comp/env/param/BookDAOClass"); bookDAO = (BookDAO)Class.forName(className).newInstance(); }catch(NamingException nex){ throw new BookDAOSysException("BookDAOFactory.getDAO: NamingException while getting DAO type:\n"+nex.getMessage()); }catch(Exception ex){ throw new BookDAOSysException("BookDAOFactory.getDAO: Exception while getting DAO type:\n"+ex.getMessage()); } return bookDAO; } } BookDAO.java: import java.sql.Exception; /***/ public interface BookDAO { // public java.util.Collection getAll()throws Exception; } ejb-jar.xml中有配置: <env-entry> <description /> <env-entry-name>param/BookDAOClass</env-entry-name> <env-entry-type>java.lang.String</env-entry-type> <env-entry-value>BookDAOImpl</env-entry-value> </env-entry> 当我用一个java类来测试时,就出现上面所说的Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial 错误,而我在配置文件(ejb-jar.xml)中有如上面所示,搞了一天 还是没有找到,请各位大侠指教 谢谢 Hibernate的优点 |
话题树型展开 |
人气 | 标题 | 作者 | 字数 | 发贴时间 |
3580 | DAO模式下连接sessionBean出错??求教 | neweagle | 2558 | 2004-06-28 17:08 |
2846 | Re:DAO模式下连接sessionBean出错??求教 | neweagle | 40 | 2004-06-28 17:36 |
已读帖子 新的帖子 被删除的帖子 |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |