39322

org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml

Question:

please help me in resolving this error.

org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1494) at org.hibernate.cfg.Configuration.configure(Configuration.java:1428) at org.jbpm.db.hibernate.HibernateHelper.createConfiguration (HibernateHelper.java:89) at org.jbpm.persistence.db.DbPersistenceServiceFactory.getConfiguration (DbPersistenceServiceFactory.java:75) at org.jbpm.persistence.db.DbPersistenceServiceFactory.getSessionFactory(DbPersistenceServiceFactory.java:104) at org.jbpm.persistence.db.DbPersistenceService.getSessionFactory(DbPersistenceService.java:93) at org.jbpm.persistence.jta.JtaDbPersistenceService.getTransactionManager(JtaDbPersistenceService.java:100) at org.jbpm.persistence.jta.JtaDbPersistenceService.getTransactionStatus(JtaDbPersistenceService.java:88) at org.jbpm.persistence.jta.JtaDbPersistenceService.<init>(JtaDbPersistenceService.java:50) at org.jbpm.persistence.jta.JtaDbPersistenceServiceFactory.openService(JtaDbPersistenceServiceFactory.java:61) at org.jbpm.svc.Services.getService(Services.java:160) at org.jbpm.svc.Services.getPersistenceService(Services.java:197) at org.jbpm.JbpmContext.getPersistenceService(JbpmContext.java:695) at org.jbpm.JbpmContext.getJobSession(JbpmContext.java:639) at org.jbpm.job.executor.LockMonitorThread.unlockOverdueJobs(LockMonitorThread.java:64) at org.jbpm.job.executor.LockMonitorThread.run(LockMonitorThread.java:43) Caused by: org.dom4j.DocumentException: Connection reset Nested exception: Connection reset at org.dom4j.io.SAXReader.read(SAXReader.java:484) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1484) ... 15 more

I am new to hibernate and having difficulty in understanding what the error is. The jar files used for hibernate are as

hibernate-annotations.jar hibernate-jpa-2.0-api-1.0.1.Final.jar hibernate3.jar

my hibernate.cfg.xml file is as

<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration SYSTEM "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/datacenter</property> <property name="connection.username">root</property> <property name="connection.password">admin</property> <!-- <property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property> --> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <property name="current_session_context_class">thread</property> <property name="show_MySql">TRUE</property> <property name="format_sql">TRUE</property> <!-- <property name="jboss.as.jpa.providerModule">hibernate3- bundled</property> --> <property name="hibernate.hbm2ddl.auto">update</property> <property name="hibernate.cache.use_second_level_cache">true</property> <!-- <property name="hibernate.query.factory_class">org.hibernate.hql.internal.classic.ClassicQueryTransla torFactory</property> --> <!-- List of annotated classes--> <!-- Associations --> <!-- One to one --> <!-- <mapping class="Emp_Timecard" /> <mapping class="maindoor" /> --> <mapping class="model.serverroom" /> <mapping class="model.resourcelist" /> <mapping class="model.timesheet" /> <mapping class="model.maindoor" /> <!-- <mapping class="timesheet" /> <mapping class="Resource_list"/> --> </session-factory> </hibernate-configuration>

Answer1:

I think you are having an issue with connecting to the db properly. Are you sure the user name and password are correct? Or did you have an already a database called datacenter?

Also try changing the doctype as

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

Answer2:

See <a href="https://stackoverflow.com/questions/4301294/cant-parse-hibernate-cfg-xml-while-offline" rel="nofollow">Can't parse hibernate.cfg.xml while offline</a>

Depending on your hibernate version it might be that hibernate is trying to load the DTD from the internet and that the connection is reset in the meantime.

Answer3:

to run hibernate application offline use 'hibernate-core jar' file it will work.. no need to change your Hibernate configuration file .Avvappa,BEL.

Answer4:

change ur hiber configuration i.e

<hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-configuration" xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

----------------------------to as below -------------------------------------

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.5//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

Answer5:

change your Hibernate configuration as follows;

<hibernate-configuration xmlns="http://www.hibernate.org/xsd/hibernate-configuration" xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-configuration hibernate-configuration-4.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ----------------------------to as below ------------------------------------- <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.5//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration>

Answer6:

<strong>Try Running the program while your system is connected to Internet</strong>

I was facing the same issue. And when i searched for the solution online found this thread regarding the same issue.

I went back and tried running the program again and it worked, the only changes made were connected to Internet Connection. I turned off the connection and again the program was giving the same error as you got.

My guess is the Hibernate configuration file is downloading the DTD from internet, and when it fails to do so it gives error while creating the SessionFactory object.

<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

Answer7:

If the configuration file is not parsed, just check for the hibernate version. If it is hibernate 3 the DTD should be from <strong>Sourceforge</strong> website. if it is the later version the DTD should be

<!DOCTYPE hibernate-configuration SYSTEM "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

Recommend

  • Joining tables without relation using JPA criteria
  • copy data from a mysql database to other mysql database with java
  • Does Java EE 6 framework only for Web Application Or can I use it for Client Application as well
  • How to do JOIN ON query using Criteria API
  • Wrapping text in spinner android
  • Splash Screen will not display
  • Xamarin Android | Layout style
  • How can I include If-None-Match header in HttpRequestMessage
  • How to convert SOAP response with xsi values to json in WSO2esb
  • C# fibonacci function returning errors
  • How to get current document uri in XSLT?
  • Convert Type Decimal to Hex (string) in .NET 3.5
  • What is the purpose of TaskExecutor in spring?
  • JBoss External Properties Files in Classpath
  • presentShareDialogWithParams posts to FB wall, but callback handler results say error
  • why xml file does not aligned properly after append the string in beginning and end of the file usin
  • htaccess add www if not subdomain, if subdomain remove www
  • Why Encoding.ASCII != ASCIIEncoding.Default in C#?
  • How to attach a node.js readable stream to a Sendgrid email?
  • JSON response opens as a file, but I can't access it with JavaScript
  • Bad request using file_get_contents for PUT request in PHP
  • how to adjust image in a panel in Java swing?
  • When to use `image` and when to use `Matrix` in Emgu CV?
  • Encrypt data by using a public key in c# and decrypt data by using a private key in php
  • Uncaught Error: Could not find module `ember-load-initializers`
  • Accessing IRQ description array within a module and displaying action names
  • Possible to stop flickering java tooltip in heavyweight mode?
  • SSO with signing and signature validation doesn't work
  • Deserializing XML into class C#
  • Hazelcast - OperationTimeoutException
  • RestKit - RKRequestDelegate does not exist
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How to include full .NET prerequisite for Wix Burn installer
  • Revoking OAuth Access Token Results in 404 Not Found
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • JTable with a ScrollPane misbehaving
  • coudnt use logback because of log4j
  • costura.fody for a dll that references another dll
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize