Just to be clear, I’m not talking about a JNDI datasource. I’m talking about a JNDI DAO. When you create a hibernate mapping for a table within the database explorer, one of the options is to create a Java Data Access Object (DAO). There are two options for the DAO type, “Spring DAO” and “JNDI DAO”. If you choose “JNDI DAO” then you must enter the JNDI path.
Are there any examples on how to use this option?
Here is some of the code it generates for the DAO:
protected SessionFactory getSessionFactory() {
try {
return (SessionFactory) new InitialContext().lookup(“java:comp/env/hibernate/SessionFactory”);
} catch (Exception e) {
log.error(“Could not locate SessionFactory in JNDI”, e);
return cfg.buildSessionFactory();
throw new IllegalStateException(“Could not locate SessionFactory in JNDI”);
}
}
Whenever I call one of the DAO functions, it calls getSessionFactory(), which generates the error:
“Could not locate SessionFactory in JNDI”