hibernate properties not found

丶灬走出姿态 提交于 2019-12-02 21:05:52
pratap m

I guess the problem is with the code for configuration you mentioned for .hbm.xml may not be working in Tomcat.

I think it needs AnnotationConfiguration object. I guess you used this code due to the Annotationconfiguration object creation is not working.

Better create a maven hibernate project with pom and export the war file to Tomcat (with the changes of Annotationconfiguration). Also use log4j jar for showing the details of Tomcat execution with the debug outputs, so that Tomcat output will print all of execution flow.

It seems to me, that you can solve this problem, by passing hibernate.cfg.xml directly into Configuration.

try (InputStream in = HibernateUtil.class.getResourceAsStream("/hibernate.cfg.xml")) {
     Configuration configuration = new Configuration().addInputStream(in).configure();
...
} ... 

The only thing, you have to properly point the path or class, for getResourceAsStream. Or you may be want to create InputStream using some relative path.

Ramesh J

I have faced the same problem but I found the solution here..

http://www.mkyong.com/hibernate/hibernate-error-an-annotationconfiguration-instance-is-required-to-use/

ie. Change the line:

new Configuration().configure().buildSessionFactory();

to:

new AnnotationConfiguration().configure().buildSessionFactory();
Dmitriy Voropay

if it is appeared that you use Intellij Idea you need to put hibernate.cfg.xml file into resources folder

and if you will have after next error: org.hibernate.service.jndi.JndiException: Error parsing JNDI name []

delete in hibernate.cfg.xml file name of tag see picture:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!