Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

org.hibernate.MappingException: Unknown entity: com.hp.ExamRegister in a struts2 tiles integration

 
Archi Sharma
Greenhorn
Posts: 15
Hibernate Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to display a layout here as is given in Layout.jsp. But I get an exception as mentioned in the subject. ExamRegister is a table in my database and i have its POJO also in package com.hp. When i run the project i get the login form i.e. index.jsp. When i enter the details in the form and click the login button the exception is reported.
Please could anybody tell me what is missing and where.
Thanks !!

tiles.xml


web.xml


struts.xml


Layout.jsp



LoginAction.java


exception
 
Campbell Ritchie
Sheriff
Posts: 51407
87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You appear to have arrived in the wrong forum; I shall try moving you to the Struts forum.
 
Archi Sharma
Greenhorn
Posts: 15
Hibernate Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks . Well, I posted again in the correct framework.
 
Joe Ess
Bartender
Posts: 9339
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This exception:

leads me to believe that this is a Hibernate issue. What is the full stack trace of the error from the Tomcat log file?
Do you have ExamRegister configured as a Hibernate entity? You don't show us the source or the Hibernate config files.
 
Archi Sharma
Greenhorn
Posts: 15
Hibernate Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following is the stack trace and the cfg file respectively.I would also like to mention that I am using Netbeans ide.



cfg


 
Joe Ess
Bartender
Posts: 9339
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exception there seems pretty straightforward:



I'd like to know why it mentions an insert to an "employee" table when your class you are fetching in LoginAction is ExamRegister. This leads me to believe that you are not showing us the full stack trace from your first post.
How did you set up ExamRegister with Hibernate? A mapping file or annotations? Can you show us the ExamRegister class and the mapping file (if any).
 
Archi Sharma
Greenhorn
Posts: 15
Hibernate Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am sorry I posted the wrong stack trace.The correct one is as follows:


exam_register is a table in my database. ExamRegister is the corresponding POJO for the table.ExamRegister class and the corresponding XML are as follows:


ExamRegister.java



ExamRegister.hbm.xml



 
Joe Ess
Bartender
Posts: 9339
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So how is Hibernate supposed to find out about ExamRegister.hbm.xml?
 
Archi Sharma
Greenhorn
Posts: 15
Hibernate Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the configuration file??
 
Arun Giridhar
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in configuration refer your hbm file

cfg
 
Archi Sharma
Greenhorn
Posts: 15
Hibernate Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did as you said Arun, but I got an exception:
 
Joe Ess
Bartender
Posts: 9339
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The mapping tag should go inside the session-factory tag.
 
Archi Sharma
Greenhorn
Posts: 15
Hibernate Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Still getting the following exception:

 
Joe Ess
Bartender
Posts: 9339
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When Arun wrote "file-path", he meant for you to put in the relative path from the Hibernate config file to the ExamRegister.hbm.xml
 
Archi Sharma
Greenhorn
Posts: 15
Hibernate Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ohh such a dumb mistake! Well, thanks for your help. Much appreciated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic