简体   繁体   中英

Web Project and Hibernate Exception

I am running a web application that uses Hibernate for data persistence.

Now I have created another webproject and included necessary jar files etc. While fetching data I got an exception.

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

My other web project is running fine. Also hibernate.cfg.xml is in its place. hibernate.cfg.xml is under EarContent/hibernate.cfg.xml

Classpath issue. Check to see which is your project root folder.

There was a problem in calling my hibernate class. I was not calling it from a jsp page. Doing so problem solved.

Before this I was calling it from a java class main method to test it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM