0

I am trying to run an application on my system . I have been told to Edit the "hibernate.cfg.xml" and provide the security credentials that I provided during the MySQL installation. These should go in:

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

I have done these settings properly. ANd when I run my application I get "Could not parse configuration: /hibernate.cfg.xml" error.

BElow is my hibernate.cfg.xml file.

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

Here is the error I am geeting:

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)

PLease can any one help in solving this problem.

Thanks

Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
galme
  • 603
  • 3
  • 10
  • 24
  • possible duplicate of [Could not parse - org.dom4j.DocumentException: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory](http://stackoverflow.com/questions/1804285/could-not-parse-org-dom4j-documentexception-org-dom4j-documentfactory-cannot) – Don Roby May 28 '14 at 10:44

1 Answers1

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

This is because you have two versions of dom4j in your class-path.

If you're using Maven than you could run:

mvn dependency:tree

to figure out what dependencies are adding two dom4j jars in your class path.

Otherwise check your application specific lib folder and look for two dom4j versions.

Vlad Mihalcea
  • 142,745
  • 71
  • 566
  • 911
  • Thanks for the reply. I am not using maven. I have only one dom4j in my lib folder. – galme May 28 '14 at 10:54
  • Are you deploying on some application server? Because some AS have global libs that may be shared among multiple deployed apps. – Vlad Mihalcea May 28 '14 at 10:56
  • I have basically got the code from SVN , configured it with Eclipse along with tomcat 7 . I started tomcat on eclipse and ran the application in browser. After I give login credentials, I am getting this exception. – galme May 28 '14 at 11:02
  • If there is no dom4j in tomcat/libs and you have only one dom4j in {app}/WEB-INF/lib than maybe it's related to eclipse. Try a manual deploy on a separate tomcat and see if it's working. – Vlad Mihalcea May 28 '14 at 11:13
  • Yes it should be some problem with the eclipse. I deployed on seperate tomcat and its working. Thanks :) – galme May 29 '14 at 06:38
  • I am glad you figured it out. Probably you got an extra dom4j dependency from Eclipse. – Vlad Mihalcea May 29 '14 at 06:48