If hibernate project is developed with hibernate
extension on Windows platform and deployed to linux app
server, the following exception is thrown:
java.lang.ExceptionInInitializerError
hibertest.HibernateUtil.getSessionFactory(HibernateUtil.java:56)
hibertest.HibernateUtil.currentSession(HibernateUtil.java:67)
hibertest.TestFacade.saveTest(TestFacade.java:11)
hibertest.TestFacade.generate(TestFacade.java:23)
org.apache.jsp.index_jsp._jspService(index_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
If properly configured, log will contain cause of
exception:
[...]
Caused by: org.hibernate.MappingException: Resource:
hibertest\Test.hbm.xml not found
at
org.hibernate.cfg.Configuration.addResource(Configuration.java:479)
at
hibertest.HibernateUtil.getSessionFactory(HibernateUtil.java:33)
[...]
This happens because the generated file
hibernateBeans.lst contains backslashes, which are not
allowed as directory separator on unix/linux platform:
hibertest\Test.hbm.xml
Proposed Fix: Since on Windows platform, the forward
slash is a valid directory separator, the plugin could
be changed so that hibernateBeans.lst is always
generated with forward slashes.
Logged In: YES
user_id=1037284
Note: As a workaround, one could put the following code into
the generated getSessionFactory() method of HibernateUtil.java:
while ((line = reader.readLine()) != null) {
String corrected = line.replace("\\", "/");
configuration.addResource(corrected);
}
instead of
while ((line = reader.readLine()) != null) {
configuration.addResource(line);
}
Logged In: YES
user_id=885974
Thanks for report it is serious problem