-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 
Author Message
 Post subject: org.hibernate.MappingException: invalid configuration
PostPosted: Thu Apr 26, 2007 5:24 am 
Newbie

Joined: Thu Apr 26, 2007 5:10 am
Posts: 3
Hi all,

I am new to hibernate ... doing simple eg but facing this exception..
plz send reply soon an dhelp me..

Kavita...


org.hibernate.MappingException: invalid configuration
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1487)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1428)
at InsertEvent.main(InsertEvent.java:28)
Caused by: org.xml.sax.SAXParseException: Document root element "hibernate-configuration", must match DOCTYPE root "hibernate-mapping".
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.rootElementSpecified(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.startElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.dom4j.io.SAXReader.read(SAXReader.java:465)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1484)
... 2 more
Exception in thread "main"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 5:34 am 
Senior
Senior

Joined: Sat Apr 21, 2007 11:01 pm
Posts: 144
looks like it can't find your hibernate config file or the one you are specifying is invalid. can you explain a bit more about what your doing and past in some source files, like your config etc.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 5:46 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
I guess....
Change doctype in hibernate.cfg.xml,
<<< <!DOCTYPE hibernate-mapping SYSTEM 'hibernate-mapping-3.0.dtd' >
>>> <!DOCTYPE hibernate-configuration SYSTEM 'hbernate-configuration-3.0.dtd' >

-------------------------------------------
Rate the reply if you find it helpful


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 5:50 am 
Newbie

Joined: Thu Apr 26, 2007 5:10 am
Posts: 3
Hi,
Thanks but my config file is well formated..i have copied my cfg file..


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">


<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@ps0560.persistent.co.in:1521:Oracl</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.connection.password">tiger</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<!-- Mapping files -->
<mapping resource="Event.hbm.xml"/>
</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 5:55 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
I re-iterate.

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-configuration>


Here,
Doctype Root and DTD : hibernate-mapping
Document Root: hibernate-configuration

You need to correct them.

----------------------------------------------------
Rate the reply if you find it helpful


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 5:58 am 
Newbie

Joined: Thu Apr 26, 2007 5:10 am
Posts: 3
Hi Pramod,
I have change it accordily .but getting some diff error..



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 InsertEvent.main(InsertEvent.java:28)
Caused by: org.dom4j.DocumentException: D:\Eclipse Workspace\MyHibernate\hibernate-mapping-3.0.dtd (The system cannot find the file specified) Nested exception: D:\Eclipse Workspace\MyHibernate\hibernate-mapping-3.0.dtd (The system cannot find the file specified)
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1484)
... 2 more
Exception in thread "main"



modified cfg.xml..


<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping SYSTEM 'hibernate-mapping-3.0.dtd' >
<!DOCTYPE hibernate-configuration SYSTEM 'hbernate-configuration-3.0.dtd' >


<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@ps0560.persistent.co.in:1521:Oracl</property>
<property name="hibernate.connection.username">scott</property>
<property name="hibernate.connection.password">tiger</property>
<property name="show_sql">true</property>
<property name="dialect">org.hibernate.dialect.OracleDialect</property>
<!-- Mapping files -->
<mapping resource="Event.hbm.xml"/>
</session-factory>
</hibernate-configuration>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 26, 2007 6:06 am 
Regular
Regular

Joined: Mon Mar 26, 2007 12:38 am
Posts: 119
Hi,
If you are new to hibernate, hibernate docs is a good place to start.
http://www.hibernate.org/hib_docs/v3/re ... l-firstapp

In your case, right now,
i) retain only the correct doctype declaration.
<!DOCTYPE hibernate-configuration SYSTEM 'hbernate-configuration-3.0.dtd' >
ii) Have DTDs in classpath


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.