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
EditHaving 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...