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

时间:2014-05-28 10:39:01

标签: java xml hibernate jpa orm

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

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

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

BElow是我的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)

任何人都可以帮助解决这个问题。

由于

1 个答案:

答案 0 :(得分:2)

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

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

如果你使用Maven而不是你可以运行:

mvn dependency:tree

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

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

相关问题