I have generated DAO from the hbm.xml file and use it in the web service deployed to the Tomcat 6.0.16.
Deployment went through fine but on servlet load I am getting the
Code:
SEVERE: Servlet /PdfService threw load() exception
java.lang.IllegalStateException: Could not locate SessionFactory in JNDI
Here is the code. I did some fiddling with it but nothing worked.
Code:
protected SessionFactory getSessionFactory() {
try {
InitialContext ic = new InitialContext();
return (SessionFactory) ic.lookup("java:comp/env/hibernate/SessionFactory");
}
catch (Exception e) {
log.error("Could not locate SessionFactory in JNDI", e);
throw new IllegalStateException("Could not locate SessionFactory in JNDI");
}
}
And here is what I have in the context.xml file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/PdfService" reloadable="true">
<Logger className="org.apache.catalina.logger.FileLogger"
prefix="pdf_svc_log." suffix=".log" timestamp="true"/>
<Resource name="hibernate/SessionFactory" auth="Container"
type="org.hibernate.SessionFactory" configuration="hibernate.cfg.xml"/>
</Context>
If some kind soul can tell me what I am doing wrong and how to do it right, I'll be very appreciative.
Thanks.