1 Reply Latest reply on Mar 28, 2006 3:25 PM by davidchen

    problem to bind hibernate session factory to JNDI

    davidchen

      Hi, there:

      Searching the forum, it seems a quite old problem, but didn't get any clear answer yet. Using JBoss-4.0.3sp1, hibernate3.jar, following document, I deployed a test har into my default/deploy directory, and I got that very famous "Not binding factory to JNDI" log, and my client side code can not find the session factory.

      My jboss-service.xml is:

      <?xml version="1.0" encoding="UTF-8"?>
      <server>
      <mbean code="org.jboss.hibernate.jmx.Hibernate" name="jboss.adminguide:name=ExampleSessionFactory">
      <attribute name="DatasourceName">java:/DefaultDS</attribute>
      <attribute name="Dialect">
       org.hibernate.dialect.Oracle9Dialect
      </attribute>
      <attribute name="SessionFactoryName">
       java:/hibernate/ExampleSessionFactory
      </attribute>
      </mbean>
      </server>
      


      And my har file doesn't include any lib jar files, only classes files and hbm.xml files. After deploying to jboss, I got logs like:
      INFO [org.hibernate.impl.SessionFactoryObjectFactory] Not binding factory to JNDI, no JNDI name configured
      INFO [org.hibernate.util.NamingHelper] JNDI InitialContext properties:{}
      INFO [org.hibernate.impl.SessionFactoryImpl] Checking 0 named queries
      INFO [org.jboss.hibernate.jmx.Hibernate] SessionFactory successfully built and bound into JNDI [java:/hibernate/ExampleSessionFactory]
      


      However, in my client code,
      (SessionFactory)ctx.lookup("java:/hibernate/ExampleSessionFactory");
      

      throws NamingException: hibernate not bound

      Could any one please give me some hints or solutions?
      Hightly appreciated if any comments or suggestions.

      Thanks a lot in advance

      David

        • 1. Re: problem to bind hibernate session factory to JNDI
          davidchen

          I guess it was my problem. It seems that HAR component is similiar to MBean, which can not be accessed directly by java client outside jboss. It seems that a easy way to access har component by outside jboss client is to through a session bean facade. Am I right?

          Highly appreciated if any comments or suggestions.

          Thanks a lot in advance
          David