WSAD5 with Hibernate

xinxin2 2003-08-19 05:44:41
有沒有人在WSAD5用過Hibernate阿﹖
我試了好長時間﹐總有錯誤﹐不知道誰能幫我。

I just have a Web Project, and inside the Java Source, I have a java class Cat.java (setter/getter), and a servlet (calling Hibernate Configure to get session), I have tried to put hibernate.cfg.xml file to each directory(WEB-INF/classes, WEB-INF, Java Source, ...), but all do not work at all, I don't know why, do you know where the .cfg.xml need to be put? Or do I need to have the .cfg.xml file path in web.xml? I have no idea.

Do you have an example about creating a web application using WSAD5 and Hibernate?

Thanks so much for helps.

The error message is:
____________________________________________________________

" I net.sf.hibernate.cfg.Configuration Configuration resource: /hibernate.cfg.xml
7bff0b53 Configuration W net.sf.hibernate.cfg.Configuration /hibernate.cfg.xml not found
7bff0b53 WebGroup E SRVE0026E: [Servlet Error]-[/hibernate.cfg.xml not found]: net.sf.hibernate.HibernateException: /hibernate.cfg.xml not found
"
__________________________________________________________

hibernate.cfg.xml
__________________________________________________________

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd"> />
<hibernate-configuration>

<session-factory>

<property name="hibernate.connection.driver_class">COM.ibm.db2.jdbc.net.DB2Driver</property>
<property name="hibernate.connection.url">jdbc:db2:JDO</property>
<property name="hibernate.connection.username">admin</property>
<property name="hibernate.connection.password">admin</property>
<property name="show_sql">true</property>
<property name="use_outer_join">true</property>
<property name="dialect">net.sf.hibernate.dialect.DB2Dialect</property>

<!-- Mapping files -->
<mapping resource="Cat.hbm.xml"/>
</session-factory>

</hibernate-configuration>
_______________________________________________________________



...全文
26 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangchq 2003-09-19
  • 打赏
  • 举报
回复
*.hbm.xml默认放在类(编译后)的同级目录
javanew 2003-09-17
  • 打赏
  • 举报
回复
不是说你的hibernate.cfg.xml没找到嘛,你虽然有,但是不一定放对了位置

我一般是放在run的那个class同一个目录

你可以试试hibernate的其他读配置的办法,比如指定hibernate.properties文件,在程序中设置等

67,513

社区成员

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

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