Reputation: 1602
I´ve just started playing around with Java and Hibernate and have gotten an application working. Everything works "perfectly" when I run it from eclipse but when I use Eclipse builtin function for packaging the project with dependencies into a jar files I get:
org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.util.xml.MappingReader.readMappingDocument(MappingReader.java:101)
at org.hibernate.cfg.Configuration.add(Configuration.java:510)
at org.hibernate.cfg.Configuration.add(Configuration.java:506)
at org.hibernate.cfg.Configuration.add(Configuration.java:686)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:771)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2314)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2280)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2260)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2213)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2128)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2107)
at myPackage.MyClass.setUp(MyClass.java:89)
The hibernate.cfg.xml and mapping.hbm.xml are both located directly in the src folder. Tthe "link" between them is:
<mapping resource="mapping.hbm.xml" />
In the resulting jar-file they both end up in the root.
Upvotes: 0
Views: 1683
Reputation: 26
Your message could have several explanations regarding XML validity.
In my case, I had the same problem the whole day but with a legacy application, so it couldn't be invalid. I just realized that there were a crash in my classpath so dfc.jar file was interfering with Hibernate when reading XML mappings.
In your case it could be a question of XML validity (as you can see all around the web), or another JAR file interfering your classpath as in my case.
I hope it helps.
Upvotes: 1