• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate -4.x What header should I use in cfg.xml file?

 
Witold Marshal
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am starting with Hibernate. i have downloaded version 4.1. What header should I use for my cfg.xml files?
In documentation there is no word about it. In their examples they are using standard (old) header:



It indicates hibernate configuration version 3.0. When I use it my basic aplication it works fine but shouldn't I use a newer header for my Hibernate 4.1?

I have found on the net en axample of such header but i doesn't work for my aplications:



So is there enything else for Hibernate 4 or should I use old type of header?
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried putting the following in your browser?



There is nothing there. Is it in the Jar? I can't see why this would work.
 
Witold Marshal
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I talk with someone who knows the xsd schema isssue very well and he says that the http doesn't have to indicate appropriate location to the xsd file because this file is in one of hiberante jars (I have found it there) and all the request for this schema are rediverted there. So this is not an answer why it doesn't work.
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am well aware it does not have to be on the internet but most good libraries will have it in both places funny that hibernate does not. But that is exactly why I asked you the question

Is it in the Jar?


I have not had the opportunity to make the leap to 4 at work yet and at home I don't use XML configuration. But here are a few things you could try:


Try the latest version if you are not using it


Check against the examples in their doc and make sure their are no differences
http://docs.jboss.org/hibernate/orm/4.1/devguide/en-US/html_single/#d5e90

There is more than one XSD, are you using the correct one for the correct purpose (there is a different XSD for your hibernate mappings, ORM, configuration etc). You really have not posted enough information to make that determination. See the below JIRA where they added this.
https://hibernate.onjira.com/browse/HHH-6080

Lastly when you say "it does not work" that does not give us much to go on, what kind of errors are you getting? Is your config invalid against the schema or is the schema just not found?
See Tell The Details
 
Witold Marshal
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I write "does not work" I mean that I get an arror concernig header. I exactly get:
ExceptionInitializerError caused by MappingException: invalid configuration
lover there is another cause:
SAXParseException: Document is ivalid: no grammar found.

As I mentioned, when I change header on old version (3) the application works perfect (although it is using libraries from Hibernate version 4.x).
Thanks for that link to documentation but my header is exactly the same. To avoid missing any difference (single letter) I have copied it to my application and doesn't work to. I suspect this is the only version of Header for Hib. 4 on the net and that is why the one I have found is the same that you have indicated in this documentation.
I haven't tried to modify this header by changing the name of xsd file because I a newbie in that issue and I rely on standard settings. I use link to standard file "hibernate-configuration-4.0.xsd".
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What hibernate jars are on your classpath? The XSD should be in the core jar which would suggest that your classpath is not correct. Could you possibly have an old version of hibernate on there?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Witold Marshal wrote: I exactly get:
ExceptionInitializerError caused by MappingException: invalid configuration
lover there is another cause:
SAXParseException: Document is ivalid: no grammar found.

Please post that entire exception stacktrace. That might give us an hint about what it's complaining about. Also post your hibernate configuration (in its entirety) which uses that xsd.
 
Witold Marshal
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My application is meant for JSE environment, JDBC connection, run from Eclipse or executable jar (in both cases result is the same).
Here you have all the materials:

My cfg.xml looks like this:



If I pack it to executable jar then I have Manifest.mf which indidcates Hibernate jars:



So the Hib. version is for sure 4.1.2

And here is whole printstack from Exceptions:




 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this in your hibernate.cfg.xml:
 
Witold Marshal
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for this new header but it gives no results as the previous one (The same error). Propably it can't find this xsd schema. The strange thing is that when I change header on this for version 3.x (3.0.dtd) it works. And both schema files (xsd and dtd) are in the same folder "org/hibernate" of Hibernate libraries.
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this instead:
 
Witold Marshal
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The same error occurs.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic