0 Replies Latest reply on Jun 1, 2011 8:27 PM by Shawn Zimmerman

    Hibernate Session and JNDI Not Found

    Shawn Zimmerman Newbie

      I am trying to get a Seam-managed Hibernate session setup in Seam 2.2.0GA with Glassfish 2.1.1.


      I get an exception:



      Caused by: java.lang.IllegalArgumentException: SessionFactory not found in JNDI: bookingDatabase
      ...
      Caused by: javax.naming.NameNotFoundException: bookingDatabase not found

      Here are key parts of my setup:


      components.xml


      <persistence:hibernate-session-factory name="hibernateSessionFactory" />
      <persistence:managed-hibernate-session name="session" auto-create="true" session-factory-jndi-name="bookingDatabase" />



      hibernate.cfg.xml


      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 2.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
      
      <hibernate-configuration>
           <session-factory name="bookingDatabase">
               <property name="transaction.flush_before_completion">true</property>
               <property name="connection.release_mode">after_statement</property>
               <property name="transaction.manager_lookup_class">org.hibernate.transaction.SunONETransactionManagerLookup</property>
               <property name="transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
               <property name="connection.datasource">jdbc/myDatabasePool</property>
                <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>         
           </session-factory>
      </hibernate-configuration>



      For the JNDI to work properly, the session-factory name in the hibernate.cfg.xml needs to be the same as the session-factory-jndi-name in the components.xml.  Is there anything else that needs to be setup?


      I have look all over the web forums, online documentation, Seam in Action and JPAwH and can't seem to figure this one out.


      Thanks,
      Shawn