I am having a very peculiar problem retrieving a Hibernate SessionFactory from JNDI. I am using JBOSS 5.1.0, Hibernate 3.3.1, and Netbeans 6.7.1.
Following is the code that I use to attempt to retrieve the SessionFactory from JNDI: (The lookup method below returns a null value)
InitialContext ctx = new InitialContext(); _session_factory = (SessionFactory) ctx.lookup("java:/hibernate/GGGoMobileSessionFactory");
SessionFactory successfully built and bound into JNDI [java:/hibernate/GGGoMobileSessionFactory]
java: Namespace ... +- hibernate (class: org.jnp.interfaces.NamingContext) | +- GGGoMobileSessionFactory (class: org.hibernate.impl.SessionFactoryImpl) ...
<hibernate-configuration xmlns="urn:jboss:hibernate-deployer:1.0"> <session-factory name="java:/hibernate/GGGoMobileSessionFactory" bean="jboss.gggomobile:name=GGGoMobileSessionFactory"> <property name="datasourceName">java:/GGGoMobileDS</property> <property name="dialect">org.hibernate.dialect.MySQLDialect</property> <depends>jboss:service=Naming</depends> <depends>jboss:service=TransactionManager</depends> </session-factory> </hibernate-configuration>