1

I am using VPS server first time to deploy my application. I have created a Hibernate Project. After Deploying it is giving me following error

org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2246) org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:230) org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:71) org.hibernate.cfg.Configuration.configure(Configuration.java:2158) org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:212) org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:71) org.hibernate.cfg.Configuration.configure(Configuration.java:2137) org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:206) util.HibernateUtil.(HibernateUtil.java:26) services.HibernateServices.(HibernateServices.java:41) servlet.GetShopProfile.processRequest(GetShopProfile.java:42) servlet.GetShopProfile.doGet(GetShopProfile.java:77) javax.servlet.http.HttpServlet.service(HttpServlet.java:621) javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

To test if my database is working fine, I created a normal database connection class and it was working fine.

hibernate.cfg.xml

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

<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>

    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/test</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password">root</property>
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.connection.pool_size">1</property>
    <property name="hibernate.current_session_context_class">thread</property>
    <!--<property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</property>-->
    <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
    <mapping class="pojo.TestClass"/>

  </session-factory>
</hibernate-configuration>

Directory Structure

WEB-INF
    classes
        pojo
            TestClass.class
        services
            HibernateService.class
        servlet
            TestServlet.class
        util
            HibernateUtil.class
        hibernate.cfg.xml

We have Tomcat 7.0 installed. Kindly help!!!

Neil Stockton
  • 11,383
  • 3
  • 34
  • 29
Kuldeep Dubey
  • 1,097
  • 2
  • 11
  • 33

3 Answers3

1

I solved the problem by reinstalling the tomcat on my server. Any ways this issue can be solved by changing the DTD as suggested in questions: here

I tried multiple solutions in my case but at last when nothing worked I reinstalled the tomcat and every thing was fine

Thanks every one for their inputs and time.

Community
  • 1
  • 1
Kuldeep Dubey
  • 1,097
  • 2
  • 11
  • 33
0

Can you try adding space in your commented lines?

<!--<property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</property>-->

Replace above line with

<!-- <property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory</property> -->

I think starting tag < after your comment start section is causing xml parsing issue.

Jeet
  • 248
  • 1
  • 8
-1

Change the hibernate.cfg.xml as

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
Akshay
  • 1,161
  • 1
  • 12
  • 33