我正在运行一个使用Hibernate进行数据持久化的Web应用程序。
现在我创建了另一个webproject并包含了必要的jar文件等。 在获取数据时,我遇到了异常。
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.util.HibernateUtil.<clinit>(Unknown Source)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
at com.core.dao.OpenIncidentDao.getAllOpenIncidents(Unknown Source)
at Test.main(Test.java:17)
Caused by: org.hibernate.HibernateException: /hibernate.cfg.xml not found
at org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:147)
at org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1405)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1427)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1414)
... 5 more
我的其他网络项目运行正常。 hibernate.cfg.xml
也取而代之。
hibernate.cfg.xml
位于EarContent / hibernate.cfg.xml
答案 0 :(得分:0)
类路径问题。检查哪个是您的项目根文件夹。
答案 1 :(得分:0)
调用我的hibernate类时出现问题。我没有从jsp页面调用它。解决了这个问题。
在此之前,我从java类main方法调用它来测试它。