-3

Working on my servlet I had this problem:

IDE tree view

org.hibernate.HibernateException: /hibernate.cfg.xml not found
    org.hibernate.internal.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:173)
    org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:2093)
    org.hibernate.cfg.Configuration.configure(Configuration.java:2074)
    org.hibernate.cfg.Configuration.configure(Configuration.java:2054)
    com.dede.app1st.controller.AddUser.doPost(AddUser.java:26)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

What is the reason for the error and how do I fix it?

Spack09
  • 212
  • 1
  • 9
  • Please update the title with a description of the problem so it is easier for people to find your question and help you. – nyarasha May 22 '18 at 19:26
  • It appears to be looking for a configuration file in the root directory and it's not there. I think there's a bad path somewhere in your setup. – Fred Larson May 22 '18 at 19:27
  • 2
    Possible duplicate of [Location of hibernate.cfg.xml in project?](https://stackoverflow.com/questions/18736594/location-of-hibernate-cfg-xml-in-project) – Vasan May 22 '18 at 19:29
  • thanks for the title :) but I do not think the problem is the same – Spack09 May 22 '18 at 19:49

1 Answers1

1

hibernate.cfg.xml seems to be searched in your classpath root, but is located in the subpackage com.dede.app1st.controller. Moving it to the root package should fix the problem.

Marcus K.
  • 980
  • 11
  • 26