[jboss-user] [JNDI and Naming] - JBoss JNDI - Hibernate sessionfactory

Divyang Dalal do-not-reply at jboss.com
Wed May 25 13:58:44 EDT 2011


Divyang Dalal [http://community.jboss.org/people/dbd1979] created the discussion

"JBoss JNDI - Hibernate sessionfactory"

To view the discussion, visit: http://community.jboss.org/message/607044#607044

--------------------------------------------------------------
I have an EJB.ear file which contains a jar for Hibernate related code. Once EJB.ear gets deployed into JBoss, I am sending a transaction to session bean which invokes Hibernate code and loads hibernate.cfg.xml.
However lookup of hibernate session factory throws a not found error. I listed the JNDI list using jmx-console and i dont see Hibernate session factory registered in JNDI. 
Should the hibernate cfg.xml be deployed in a different manner (possibly outside of jar) for hibernate session factory to be registered in JNDI ?  Is it not possible to register objects in JNDI from within application code/configuration after JBoss has started ?


12:29:14,064 INFO  [Configuration] Configuration resource: managed-hibernate.cfg.xml
12:29:14,095 INFO  [Configuration] Reading mappings from resource : IteratorInfo.hbm.xml
12:29:15,220 INFO  [HbmBinder] Mapping class: com.hibernate.test.IteratorInfo -> ITERATORINFO
12:29:15,392 INFO  [Configuration] Configured SessionFactory: java:/HibernatorSessionFactory


hibernate.cfg.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC -//Hibernate/Hibernate Configuration DTD 3.0//EN
        http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd>
<hibernate-configuration>    
    <session-factory name="java:/HibernatorSessionFactory">
        <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
        <property name="show_sql">true</property>
        <property name="hibernate.connection.datasource">java:/OracleDS</property>


Code to lookup:

 
 
 
 
InitialContext ctx   = new InitialContext();
 
 
 
 
 
 
sessionFactory  = (SessionFactory)ctx.lookup("java:/HibernatorSessionFactory");
 


Error:

12:49:35,322 ERROR [STDERR] javax.naming.NameNotFoundException: java:/HibernatorSessionFactory not bound
12:49:35,322 ERROR [STDERR]     at org.jnp.server.NamingServer.getBinding(NamingServer.java:771)
12:49:35,322 ERROR [STDERR]     at org.jnp.server.NamingServer.getBinding(NamingServer.java:779)
12:49:35,322 ERROR [STDERR]     at org.jnp.server.NamingServer.getObject(NamingServer.java:785)
12:49:35,322 ERROR [STDERR]     at org.jnp.server.NamingServer.lookup(NamingServer.java:443)
12:49:35,322 ERROR [STDERR]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:726)
12:49:35,322 ERROR [STDERR]     at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:686)
12:49:35,322 ERROR [STDERR]     at javax.naming.InitialContext.lookup(InitialContext.java:392)
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/607044#607044]

Start a new discussion in JNDI and Naming at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110525/855231a2/attachment-0001.html 


More information about the jboss-user mailing list