Forums Register Login

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

+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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".
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
 

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.
+Pie Number of slices to send: Send
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:




+Pie Number of slices to send: Send
Try this in your hibernate.cfg.xml:
+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
Try this instead:
+Pie Number of slices to send: Send
The same error occurs.
I'm gonna teach you a lesson! Start by looking at this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 17701 times.
Similar Threads
Could not parse configuration: /hibernate.cfg.xml
Requested resource is not available using Hibernate
Hibernate - the headder for *.hbm.xml file
Could not parse hibernate.cfg.xml
hibernate exception
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 02:08:23.