-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: hibernate.cfg.xml referring to jar in servlet
PostPosted: Wed Apr 03, 2013 8:18 am 
Newbie

Joined: Wed Apr 03, 2013 7:18 am
Posts: 1
Hi!

I have a simple servlet, that uses myLib.jar from another project. This jar has mapping files and database classes.

My hibernate.cfg.xml has:
Code:
    <!-- mapping files are in the jar file -->
    <mapping jar="/WEB-INF/lib/myLib.jar"/>


I tried relative path too, but I always get:
Code:
SEVERE: org.hibernate.InvalidMappingException: Could not read mapping documents from jar: myLib.jar
   at org.hibernate.cfg.Configuration.addJar(Configuration.java:607)
   at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1591)
   at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1555)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1534)
   at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1508)
...
Caused by: java.io.FileNotFoundException: /WEB-INF/lib/myLib.jar (File or directory does not exist)
   at java.util.zip.ZipFile.open(Native Method)
   at java.util.zip.ZipFile.<init>(ZipFile.java:214)
   at java.util.zip.ZipFile.<init>(ZipFile.java:144)
   at java.util.jar.JarFile.<init>(JarFile.java:153)
   at java.util.jar.JarFile.<init>(JarFile.java:117)
   at org.hibernate.cfg.Configuration.addJar(Configuration.java:604)
   ... 50 more


I wonder what is the correct way to refer to the jar file in this case. The files in the build directory seem to be in a good place:
hibernate.cfg.xml in WEB-INF/classes/
myLib.jar in WEB-INF/lib/

I am using GlassFish server.

BR,
JP


Edit
Having the classes and hbm files in the classes directory seems to work. Maybe I could still have java code as jar but only have the hbm files not jar'd, and use annotations to get rid of hbm altogether...


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.