Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java org.hibernate.hibernateeexception:无法分析配置:hibernate.cfg.xml_Java_Hibernate - Fatal编程技术网

Java org.hibernate.hibernateeexception:无法分析配置:hibernate.cfg.xml

Java org.hibernate.hibernateeexception:无法分析配置:hibernate.cfg.xml,java,hibernate,Java,Hibernate,请帮助我解决这个错误 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

请帮助我解决这个错误

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
我的
hibernate.cfg.xml文件如下

<?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>

com.mysql.jdbc.Driver
jdbc:mysql://localhost:3306/datacenter
根
管理
org.hibernate.dialogue.mysqldialogue
线
真的
真的
更新
真的

我认为您在正确连接数据库时遇到了问题。您确定用户名和密码正确吗?或者您是否已经有了一个名为数据中心的数据库

还可以尝试将doctype更改为

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

请参见


根据您的hibernate版本,可能是hibernate正在尝试从internet加载DTD,同时连接被重置。

按如下所示更改您的hibernate配置

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

----------------------------如下-------------------------------------

更改高层配置,即

<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">

----------------------------如下-------------------------------------

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


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

我也面临同样的问题。当我在网上搜索解决方案时,我发现了这个关于同一问题的帖子

我回去试着再次运行这个程序,它成功了,唯一的改变是连接到互联网。我关闭了连接,程序再次给出与您相同的错误

我的猜测是Hibernate配置文件正在从internet下载DTD,当它无法下载DTD时,它会在创建SessionFactory对象时出错

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

要脱机运行hibernate应用程序,请使用“hibernate core jar”文件,该文件将正常工作。。
无需更改Hibernate配置文件。Avvappa,BEL。

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

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

我尝试更改doctype,但仍然出现相同的错误,是的,我已为连接数据库输入了正确的密码和用户名。已经有一个名为数据中心的数据库。我也通过运行一个单独的JAVA程序来检查连接。。我还可以做些什么来解决错误plz帮助。。
<!DOCTYPE hibernate-configuration SYSTEM  
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">