Search code examples
javahibernatetomcatjndisessionfactory

Hibernate SessionFactory: how to configure JNDI in Tomcat?


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 ?


Solution

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

    But other answers are welcome as well.