Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

InvalidMappingException

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator






Following is printed
1.
2.
org.hibernate.InvalidMappingException: Could not parse mapping document from resource Login.hbm.xml

C:\myws\testhibernateproject\JavaSource\local\aaa\testhibernateproject\hiber
nate-->Login.java(POJO) and TestHibernate.java


c:\myws\testhibernateproject\WebContent\WEB-INF\classes-->

hibernate.cfg.xml
Login.hbm.xml

What is it that I am doing wrong?

[ October 21, 2008: Message edited by: shah rah ]
[ October 21, 2008: Message edited by: shah rah ]
 
Sheriff
Posts: 10445
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is this all that you see in the exception? If not, please post the entire exception stacktrace. Also ensure that you have placed this hbm.xml file at the right location. What location have your specified in your hibernate.cfg.xml file? Can you post the contents of that file?
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it because, the ID column is auto-increment in your actual database table? It should not, because you are implmenting auto-increment through Hibernate. It should be something like int, integer, number or something.

Lets give a try after changing.
 
shah rah
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the code.. THere is no stack race and I get only one line of error

RAD: v6
Hibernate: hibernate-distribution-3.3.1.GA-dist.zip
mysqldrivwer: mysql-connector-java-5.1.6
JDK 1.5



C:\myws\testhibernateproject\WebContent\WEB-INF\classes\Login.hbm.xml



C:\myws\testhibernateproject\WebContent\WEB-INF\classes\Hibernate.cfg.xml---> the db connection works if I write a JDBC program with below parameters







C:\myws\testhibernateproject\JavaSource\local\aaa\testhibernateproject\hibernate\TestHibernate.java



[ October 22, 2008: Message edited by: shah rah ]
[ October 22, 2008: Message edited by: shah rah ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no Exception stack trace in your post. From one of the line you mentioned, it looks it is unable to locate your Login.hbm.xml
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you using hibernate.cfg.xml and configuring your SessionFactory programatically? Pick one or the other.

As Adeel mentions, the reason you see this is because Hibernate cannot find the mapping file you are trying to add to the configuration.

If you do this:

you asking Hibernate to find a resource called "Login.hbm.xml" that is located in the default package.

If you do this:

you are asking Hibernate to configure a resource from a file (assuming you are not using annotations) called "Login.hbm.xml" that sits in the same package as your class file. So if the fully qualified name of your class is local.aaa.testhibernateproject.hibernate.Login your mapping file must be in the folder local/aaa/testhibernateproject/hibernate/. Given Hibernate cannot find this file, I assume this is not the case.

If you do this:

you are asking Hibernate to configure a SessionFactory based on the resources it finds in hibernate.cfg.xml. Currently, this will require a file called "Login.hbm.xml" existing in the default package.
 
shah rah
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I followed this tutorial and it works fine now.

http://www.hibernate.org/hib_docs/v3/reference/en/html/tutorial-firstapp.html
 
But how did the elephant get like that? What did you do? I think all we can do now is read this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic