Hibernate SessionFactory: how to configure JNDI in Tomcat?

EugeneP picture EugeneP · Mar 19, 2010 · Viewed 8.3k times · Source

that's how the session factory should be gotten:

    protected SessionFactory getSessionFactory() {
        try {
            return (SessionFactory) new InitialContext()
                    .lookup("SessionFactory");
        } catch (Exception e) {
        }
    }

Please provide a simple solution for Tomcat6 to be able to get SessionFactory thru simple jndi lookup in Java code. What should be written in what file on the side of Tomcat ?

Answer

EugeneP picture EugeneP · Mar 19, 2010

Here's a link http://community.jboss.org/wiki/UsingJNDI-boundSessionFactorywithTomcat41

But other answers are welcome as well.