0

I got problem,could not parsing configuration hiberenate.cfg.xml

<hibernate-configuration>
<session-factory>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521/XE</property>
<property name="connection.username">system</property>
<property name="connection.password">system</property>
<property name="dialect">org.hibernate.OracleDialect</property>
<property name="show_sql">true</property>
<mapping calss="com.jlcindia.hibernate/Customer"/>
</session-factory>
</hibernate-configuration>   

Here is the exception...

Exception in thread "main" java.lang.ExceptionInInitializerError
at com.jlcindia.hibernate.AHLab2Client.main(AHLab2Client.java:15)
Caused by: org.hibernate.HibernateException: problem parsing
configurationhibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1291)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1230)
at com.jlcindia.hibernate.AHibernateUtil.<clinit>(AHibernateUtil.java:15)
... 1 more
Caused by: org.hibernate.MappingException: invalid configuration
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1287)
... 3 more
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 25; Document
is invalid: no grammar found.
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.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
atorg.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:334)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1286)
... 3 more

I checked my DB and all the tag here but i am also not able to solve it. plese help me.

3
  • 2
    I'm going to be rude, so I apologize in advance. The problem is that you cannot read. You cannot read the error message that comes out of that, which somewhere says invalid attribute calss... because you misspelled the word class. Commented Oct 17, 2013 at 15:43
  • ok,i done it, than also i am getting problem Commented Oct 17, 2013 at 15:59
  • Duplicate of: stackoverflow.com/questions/12288516/… Commented Oct 17, 2013 at 16:02

2 Answers 2

1

There are 2 mistakes with this line

<mapping calss="com.jlcindia.hibernate/Customer"/>
  1. class is mis-spelled as calss.

  2. com.jlcindia.hibernate/Customer should have been com.jlcindia.hibernate.Customer - I'm assuming that this is the entity class.

After correcting the 2 mistakes, that line should something like this

<mapping class="com.jlcindia.hibernate.Customer" />

Side Note: A good IDE would have highlighted the error in the xml file then and there(with where exactly the error is). I suggest you use one(in case you're not using any).

Sign up to request clarification or add additional context in comments.

2 Comments

i correct all tag now i also getting same exception . and it shows that ... lineNumber: 1; columnNumber: 25; Document is invalid: no grammar found. it is not reaching end at <mapping class="com.jlcindia.hibernate.Customer"></mapping> .
This exception coming after adding Doctype header. Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.util.ReflectHelper.classForName(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Class; at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:752) at com.jlcindia.hibernate.AHibernateUtil.<clinit>(AHibernateUtil.java:17) at com.jlcindia.hibernate.AHLab2Client.main(AHLab2Client.java:15)
0

The stacktrace is stating that the doctype header is missing - add the line

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

at the start of the XML configuration file

There is an additional / which is terminating the tag early also a "class" typo both in the mapping tag . Replace

<mapping calss="com.jlcindia.hibernate/Customer"/>

with

<mapping class="com.jlcindia.hibernate.Customer"/>

5 Comments

we can end the mapping tag like this or not. i think its correct.
Did you try adding the header?
after adding doctype header tahn...ths exception coming... Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.util.ReflectHelper.classForName(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Class; at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:752) at com.jlcindia.hibernate.AHibernateUtil.<clinit>(AHibernateUtil.java:17) at com.jlcindia.hibernate.AHLab2Client.main(AHLab2Client.java:15)
That's a different issue (related to the version of the jars that you're using) and deserves its own question. The parser appears to be parsing the config file successfully now
Caused by: org.hibernate.MappingException: Resource:com.jlcindia.hibernate/hibernate.hbm.xml not found at org.hibernate.cfg.Configuration.addResource (Configuration.java:442) at org. hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1381)at org.hibernate.cfg.Configuration.parseSessionFactory (Configuration.java:1353 at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1335)at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1302)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.