• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with mapping .xml file with POJO...

 
Mike Tihonchik
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,
I am new to Hibernate (couple days). I got this error while running my program:
org.hibernate.InvalidMappingException: Could not parse mapping document from invalid mapping

Now I have looked on internet and none of the solutions seems to help me. Here is my files:
derby.cfg.xml


servers.hbm.xml


and my POJO:
Server.java


Now the only thing that might be different from everybody else, is that I am using IntelliJ IDEA 7.0.4 as my development tool...
Thank you, any suggestions would be highly appreciated...
mike
 
Paul Clapham
Sheriff
Posts: 21554
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You say you have a file named "server.hbm.xml" but you also have an XML document which refers to "servers.hbm.xml".
 
Mike Tihonchik
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:You say you have a file named "server.hbm.xml" but you also have an XML document which refers to "servers.hbm.xml".


Got you, its just a typo...
 
Paul Clapham
Sheriff
Posts: 21554
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem solved, then?
 
Mike Tihonchik
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:Problem solved, then?


No, it was a typo when I was writing a post...
 
Paul Clapham
Sheriff
Posts: 21554
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I see. Since the message is complaining about invalid mapping, there's most likely an error in one of your XML files. So you should look at the actual XML files you have on your computer. Try to ensure they are well-formed and valid according to their DTDs. I wouldn't be surprised if IDEA had that capability somewhere.

And when you start your application, look at what is logged by Hibernate before that message appears. That should tell you what parts of what documents it did manage to parse.
 
Mike Tihonchik
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I removed everything from the servers.hbm.xml to look like this:

and adjusted my POJO accordingly (to have only one String of masterKey). It still throws the error... I don't think there is a problem with form and validity of xml's themselves, because if I remove the line

from derby.cfg.xml, I get the connection and I am able to query database, and bring results back....
 
Paul Clapham
Sheriff
Posts: 21554
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So no matter what you put in servers.hbm.xml, you still get the same error? (Hint: try putting rubbish in it.) If so, that simply means that Hibernate can't find it.
 
Mike Tihonchik
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:So no matter what you put in servers.hbm.xml, you still get the same error? (Hint: try putting rubbish in it.) If so, that simply means that Hibernate can't find it.


That might be the case... I did put some random tags and still got the same error... What is confusing to me if it can't find it, why??? I moved it to the source directory [where my hibernate.cfg.xml and derby.cfg.xml are located] and still the same error persist... The only other thing, I had an exception before that told me specifically that it could not find the mapping class (which was different exception from what I am getting now). I was getting "not found" exception when I wrongly specified path in hibernate.cfg.xml file to the mapping.
 
Paul Clapham
Sheriff
Posts: 21554
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Tihonchik wrote:I moved it to the source directory [where my hibernate.cfg.xml and derby.cfg.xml are located] and still the same error persist...

But doesn't your configuration say it's in a directory called "database" under that?
 
Mike Tihonchik
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:
Mike Tihonchik wrote:I moved it to the source directory [where my hibernate.cfg.xml and derby.cfg.xml are located] and still the same error persist...

But doesn't your configuration say it's in a directory called "database" under that?


I moved both my xml and pojo out of it, just to make sure that directory structure was not affecting anything...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic