sessionfactory « Tomcat « JPA Q&A

1. Hibernate SessionFactory: how to configure JNDI in Tomcat?

that's how the session factory should be gotten:

    protected SessionFactory getSessionFactory() {
        try {

3. Problem with access to SessionFactory in JNDI, Tomcat 5.5

Hi I use Hibernate-Version: 3.2.0.cr5 apache-tomcat-5.5.17 In hibernate.cfg.xml I put Code: HibernateSessionFactory Also made listener with code: Code: sessionFactory = new Configuration().configure().buildSessionFactory(); After this I receive SessionFactory by: Code: initCtx = new InitialContext(); SessionFactory ses = (SessionFactory) envCtx.lookup("HibernateSessionFactory"); So, where is the problem ? :) I want to map SessionFactory object in JNDI with name "java:comp/env" for example. When I ...

4. Hibernate won't build SessionFactory under Eclipse Tomcat

I'm using Hibernate 3.3, Tomcat 6, and Eclipse Galileo and I get the following exception from Configuration.configure().buildSessionFactory(): 13:00:35,843 INFO SessionFactoryObjectFactory:109 - Factory name: java:comp/env/jdbc/bmf 13:00:35,843 INFO NamingHelper:49 - JNDI InitialContext properties:{} 13:00:35,843 WARN SessionFactoryObjectFactory:121 - Could not bind factory to JNDI javax.naming.NamingException: Context is read only at org.apache.naming.NamingContext.checkWritable( at org.apache.naming.NamingContext.bind( at org.apache.naming.NamingContext.rebind( at org.hibernate.util.NamingHelper.bind( at org.hibernate.impl.SessionFactoryObjectFactory.addInstance( at org.hibernate.impl.SessionFactoryImpl.( at org.hibernate.cfg.Configuration.buildSessionFactory( ... ...