title: "Could not locate SessionFactory in JNDI" with Hibernate in Jetty under Eclipse Juno
body: <p>I've spent a few days understanding this problem, but I have not come up with a solution.  The following are posts that are having similar problems:
  <a href="https://stackoverflow.com/questions/7714899/jetty-data-source-hibernate-datasource-not-found">Similar Post 1</a>, <a href="https://stackoverflow.com/questions/1620612/problems-using-eclipse-hibernate-plugin-could-not-locate-sessionfactory-in-jnd">Similar Post 2</a>, <a href="https://stackoverflow.com/questions/8818198/hibernate-sessionfactory-as-a-global-jndi-resource">Similar Post 3</a>.  I have tried some of the partial solutions there, but nothing has resolved the problem.</p>
  
  <h2>Problem</h2>
  
  <p>I'm developing a Google Web Application and using Hibernate for the persistence layer to connect to a Postgresql database.  I run it in development mode with the built-in Jetty server that comes with the GWT Eclipse plugin.  I have received some help from this <a href="https://stackoverflow.com/questions/5454421/gwt-jetty-jndi-lookup-fails">post</a> in configuring the Jetty server.</p>
  
  <p>I have used the Hibernate Tools to reverse engineer and export the following:</p>
  
  <ul>
  <li>Domain Code (.java)</li>
  <li>Hibernate XML Mappings (.hbm.xml)</li>
  <li>DAO code (.java)</li>
  <li>Hibernate XML Configuration</li>
  </ul>
  
  <p>These have all been exported to the src folder, and I've verified using the Hibernate Tool that the configurations are at least able to pull schema information.</p>
  
  <p>Now the problem comes after the Jetty server starts running.  As soon as you visit the site associated with the application, it reports the following errors in Eclipse's debug console:</p>
  
  <pre><code>    com.site.application.&lt;reverse engineered DAO&gt; getSessionFactory
      SEVERE: Could not locate SessionFactory in JNDI
      javax.naming.NameNotFoundException; remaining name 'SessionFactory'
          at org.mortbay.naming.NamingContext.lookup(NamingContext.java:578)
          at org.mortbay.naming.NamingContext.lookup(NamingContext.java:680)
          at org.mortbay.naming.local.localContextRoot.lookup(localContextRoot.java:164)
          at javax.naming.InitialContext.lookup(InitialContext.java:411)
          at com.site.application.&lt;reverse engineered DAO&gt;.getSessionFactory(&lt;reverse engineered DAO&gt;.java:31)
  </code></pre>
  
  <p>Ending with:</p>
  
  <pre><code>    [ERROR] 500 - POST &lt;application path&gt; (127.0.0.1) xxxx bytes
  </code></pre>
  
  <p>Please let me know if you need any more details.  I did not want to inundate the page with debug information.</p>
  
  <h2>Environment</h2>
  
  <ul>
  <li>Ubuntu 12.04 LTS</li>
  <li>Eclipse Juno 4.2 Build id: 20120614-1722</li>
  <li>GWT SDK 2.4.0</li>
  <li>Hibernate 4.0</li>
  <li>Postgresql 9.1</li>
  </ul>