org.hibernate.HibernateException:无法解析配置:hibernate.cfg.xml

请帮我解决这个错误。

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.(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 

我是新手,并且很难理解错误是什么。 用于hibernate的jar文件是

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

我的hibernate.cfg.xml文件是

     com.mysql.jdbc.Driver jdbc:mysql://localhost:3306/datacenter root admin <!-- org.hibernate.connection.C3P0ConnectionProvider --> org.hibernate.dialect.MySQLDialect thread TRUE TRUE <!-- hibernate3- bundled --> update true <!-- org.hibernate.hql.internal.classic.ClassicQueryTransla torFactory -->    <!--   -->     <!--   -->   

我认为你正确地连接到数据库有问题。 您确定用户名和密码是否正确? 或者你有一个名为datacenter的数据库?

同时尝试将doctype更改为

  

请参阅脱机时无法解析hibernate.cfg.xml

根据你的hibernate版本,可能是hibernate试图从互联网加载DTD并且同时重置连接。

运行hibernate应用程序离线使用’hibernate-core jar’文件它将工作..无需更改您的Hibernate配置文件.Avvappa,BEL。

改变你的hiber配置即

  

—————————-如下——————- ——————

  

更改您的Hibernate配置如下;

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

尝试在系统连接到Internet时运行该程序

我面临同样的问题。 当我在网上搜索解决方案时发现这个线程有关同一问题。

我回去尝试再次运行该程序,它工作,所做的唯一更改连接到Internet连接。 我关闭了连接,程序再次给出了同样的错误。

我的猜测是Hibernate配置文件正在从互联网上下载DTD,当它无法这样做时,它会在创建SessionFactory对象时出错。

   

如果未解析配置文件,只需检查hibernate版本。 如果是hibernate 3,DTD应该来自Sourceforge网站。 如果它是DTD应该的更高版本