- This topic has 3 replies, 2 voices, and was last updated 18 years, 2 months ago by Riyad Kalla.
-
AuthorPosts
-
prasannarupanMemberHi ,
I tried to get familiar with Hibernate using the example in MyEclipse Hibernate Quickstart guide & I got this error. I’m unable to fix this as I’m new to using Hibernate.log4j:WARN No appenders could be found for logger (net.sf.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
%%%% Error Creating SessionFactory %%%%
net.sf.hibernate.MappingException: Error reading resource: com/genuitec/hibernate/Bonus.hbm.xml
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:339)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:1018)
at net.sf.hibernate.cfg.Configuration.doConfigure(Configuration.java:974)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:902)
at com.genuitec.hibernate.SessionManager.currentSession(SessionManager.java:48)
at com.genuitec.hibernate.HibernateTest.main(HibernateTest.java:27)
Caused by: net.sf.hibernate.MappingException: invalid mapping
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:287)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:336)
… 5 more
Caused by: org.xml.sax.SAXParseException: The content of element type “class” must match “(meta*,(cache|jcs-cache)?,(id|composite-id),discriminator?,(version|timestamp)?,(property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,(subclass*|joined-subclass*))”.
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.handleEndElement(Unknown Source)
at org.apache.xerces.impl.dtd.XMLDTDValidator.endElement(Unknown Source)
at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(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.DTDConfiguration.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:339)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:286)
… 6 more
Exception in thread “main” java.lang.NullPointerException
at com.genuitec.hibernate.SessionManager.currentSession(SessionManager.java:56)
at com.genuitec.hibernate.HibernateTest.main(HibernateTest.java:27)Somebody please be kind enough to help me.
Thanks
prasanna 😕
Riyad KallaMemberChances are when you created the Bonus table you forget to set a primary key, so when you reverse engineer the table, the generated hbm.xml file is getting generated without a <id> field which is required, which is why you are seeing that error.
prasannarupanMemberHi Riyad,
Thanks Alot for your help. It works fine now.Regards
prasanna
Riyad KallaMemberGlad to hear it, thanks for following up.
-
AuthorPosts