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)
Code:
InitialContext ctx = new InitialContext();
_session_factory = (SessionFactory) ctx.lookup("java:/hibernate/GGGoMobileSessionFactory");
From looking at the server logs, I can see the SessionFactory being created and bound to JNDI
(see below).
Code:
SessionFactory successfully built and bound into JNDI [java:/hibernate/GGGoMobileSessionFactory]
If I use the JNDIView MBean to look at objects in JNDI, I clearly see the HibernateSessionFactory present in the JNDI.
(see below)Code:
java: Namespace
...
+- hibernate (class: org.jnp.interfaces.NamingContext)
| +- GGGoMobileSessionFactory (class: org.hibernate.impl.SessionFactoryImpl)
...
Following are the contents of the
gggomobile-hibernate.xml that is used to define the parameters of the Hibernate SessionFactory so it can automatically be started by JBOSS.
Code:
<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>
Does anyone have an idea on this issue ? Very very very strange !!