gpt4 book ai didi

java - 无法解析配置 :/hibernate. cfg.xml 异常

转载 作者:行者123 更新时间:2023-12-02 05:47:30 25 4
gpt4 key购买 nike

我正在尝试在我的系统上运行应用程序。我被告知编辑“hibernate.cfg.xml”并提供我在 MySQL 安装期间提供的安全凭证。 这些应该放入:

 <property name="hibernate.connection.username">USER_NAME</property>
<property name="hibernate.connection.password">PASSWORD</property>

我已经正确完成了这些设置。当我运行我的应用程序时,我收到“无法解析配置:/hibernate.cfg.xml”错误。

下面是我的 hibernate.cfg.xml 文件。

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

<!--
Endeavour Agile ALM
Copyright (C) 2009 Ezequiel Cuellar

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<hibernate-configuration>
<session-factory>

<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost/endeavour</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">dianita</property>

<property name="hibernate.c3p0.min_size">5</property>
<property name="hibernate.c3p0.max_size">20</property>
<property name="hibernate.c3p0.timeout">300</property>
<property name="hibernate.c3p0.max_statements">50</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>

<!-- SQL to stdout logging
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="use_sql_comments">true</property>
-->

<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

<mapping resource="org/endeavour/mgmt/model/ProjectMember.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Project.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Iteration.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/WorkProduct.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/TestCase.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/TestPlan.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/TestRun.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Document.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Version.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Defect.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Task.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Dependency.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/ChangeRequest.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/UseCase.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Actor.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Event.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Attachment.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Comment.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/GlossaryTerm.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/SecurityGroup.hbm.xml"/>
<mapping resource="org/endeavour/mgmt/model/Privilege.hbm.xml"/>

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

这是我遇到的错误:

org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1528)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1448)
at org.endeavour.mgmt.model.persistence.SessionFactoryManager.<init>(SessionFactoryManager.java:38)
at org.endeavour.mgmt.model.persistence.SessionFactoryManager.getInstance(SessionFactoryManager.java:43)
at org.endeavour.mgmt.model.persistence.PersistenceManager.beginTransaction(PersistenceManager.java:52)
at org.endeavour.mgmt.controller.ApplicationController.startUnitOfWork(ApplicationController.java:45)
at org.endeavour.mgmt.view.LoginView.login(LoginView.java:132)
at org.endeavour.mgmt.view.LoginView.actionPerformed(LoginView.java:126)
at thinwire.ui.EventListenerImpl.fireEvent(EventListenerImpl.java:313)
at thinwire.ui.EventListenerImpl.fireAction(EventListenerImpl.java:245)
at thinwire.ui.AbstractComponent.fireAction(AbstractComponent.java:222)
at thinwire.ui.Button.fireAction(Button.java:1)
at thinwire.render.web.ComponentRenderer.componentChange(ComponentRenderer.java:375)
at thinwire.render.web.EventProcessor.processUserActionEvent(EventProcessor.java:129)
at thinwire.render.web.EventProcessor.run(EventProcessor.java:85)
Caused by: org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)
... 15 more
org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1448)
at org.endeavour.mgmt.model.persistence.SessionFactoryManager.<init>(SessionFactoryManager.java:38)
at org.endeavour.mgmt.model.persistence.SessionFactoryManager.getInstance(SessionFactoryManager.java:43)
at org.endeavour.mgmt.model.persistence.PersistenceManager.beginTransaction(PersistenceManager.java:52)
at org.endeavour.mgmt.controller.ApplicationController.startUnitOfWork(ApplicationController.java:45)
at org.endeavour.mgmt.view.LoginView.login(LoginView.java:132)
at org.endeavour.mgmt.view.LoginView.actionPerformed(LoginView.java:126)
at thinwire.ui.EventListenerImpl.fireEvent(EventListenerImpl.java:313)
at thinwire.ui.EventListenerImpl.fireAction(EventListenerImpl.java:245)
at thinwire.ui.AbstractComponent.fireAction(AbstractComponent.java:222)
at thinwire.ui.Button.fireAction(Button.java:1)
at thinwire.render.web.ComponentRenderer.componentChange(ComponentRenderer.java:375)
at thinwire.render.web.EventProcessor.processUserActionEvent(EventProcessor.java:129)
at thinwire.render.web.EventProcessor.run(EventProcessor.java:85)
Nested exception:
java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory
at org.dom4j.DocumentFactory.getInstance(DocumentFactory.java:97)
at org.dom4j.io.SAXReader.getDocumentFactory(SAXReader.java:645)
at org.dom4j.io.SAXReader.createContentHandler(SAXReader.java:969)
at org.dom4j.io.SAXReader.read(SAXReader.java:449)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1448)
at org.endeavour.mgmt.model.persistence.SessionFactoryManager.<init>(SessionFactoryManager.java:38)
at org.endeavour.mgmt.model.persistence.SessionFactoryManager.getInstance(SessionFactoryManager.java:43)
at org.endeavour.mgmt.model.persistence.PersistenceManager.beginTransaction(PersistenceManager.java:52)
at org.endeavour.mgmt.controller.ApplicationController.startUnitOfWork(ApplicationController.java:45)
at org.endeavour.mgmt.view.LoginView.login(LoginView.java:132)
at org.endeavour.mgmt.view.LoginView.actionPerformed(LoginView.java:126)
at thinwire.ui.EventListenerImpl.fireEvent(EventListenerImpl.java:313)
at thinwire.ui.EventListenerImpl.fireAction(EventListenerImpl.java:245)
at thinwire.ui.AbstractComponent.fireAction(AbstractComponent.java:222)
at thinwire.ui.Button.fireAction(Button.java:1)
at thinwire.render.web.ComponentRenderer.componentChange(ComponentRenderer.java:375)
at thinwire.render.web.EventProcessor.processUserActionEvent(EventProcessor.java:129)
at thinwire.render.web.EventProcessor.run(EventProcessor.java:85)

请任何人帮助解决这个问题。

谢谢

最佳答案

java.lang.ClassCastException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory

这是因为您的类路径中有两个版本的 dom4j。

如果您使用 Maven,则可以运行:

mvn dependency:tree

找出哪些依赖项在类路径中添加了两个 dom4j jar。

否则检查您的应用程序特定的 lib 文件夹并查找两个 dom4j 版本。

关于java - 无法解析配置 :/hibernate. cfg.xml 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23909344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com