title: Jetty Data Source, Hibernate, datasource not found
body: <p>I'm attempting to configure a data source in Jetty 7.4.  I was able to do this successfully with my webapp in a Tomcat context.xml.</p>
  
  <p>Here's what I have in the jetty.xml (this is going to be the only application in this jetty instance, so I don't mind having the DB connection server-wide - I'd rather not have to configure it inside the war).  It's at the very bottom just above the last <code>&lt;/Configure&gt;</code>:</p>
  
  <pre><code>&lt;New class="org.eclipse.jetty.plus.jndi.Resource" id="myDB"&gt;
      &lt;Arg&gt;
        &lt;Ref id="Server"/&gt;
      &lt;/Arg&gt;
      &lt;Arg&gt;jdbc/myDB&lt;/Arg&gt;
      &lt;Arg&gt;
          &lt;New class="com.microsoft.sqlserver.jdbc.SQLServerDataSource"&gt;
              &lt;Set name="URL"&gt;jdbc:sqlserver://SERVERNAME;databaseName=DATABASENAME;sendStringParametersAsUnicode=false&lt;/Set&gt;
              &lt;Set name="user"&gt;USERNAME&lt;/Set&gt;
              &lt;Set name="password"&gt;PASSWORD&lt;/Set&gt;
          &lt;/New&gt;
      &lt;/Arg&gt;
  &lt;/New&gt;
  </code></pre>
  
  <p>In my webapp's WEB-INF/web.xml:</p>
  
  <pre><code>&lt;resource-ref&gt;
    &lt;description&gt;Database Connection&lt;/description&gt;
    &lt;res-ref-name&gt;jdbc/myDB&lt;/res-ref-name&gt;
    &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
    &lt;res-auth&gt;Container&lt;/res-auth&gt;
  &lt;/resource-ref&gt;
  </code></pre>
  
  <p>Finally, in my hibernate.cfg.xml:</p>
  
  <pre><code>&lt;property name="connection.datasource"&gt;java:comp/env/jdbc/myDB&lt;/property&gt;
  </code></pre>
  
  <p>Yet, I'm getting a datasource not found error, and I also see the following NameNotFoundException:</p>
  
  <pre><code>javax.naming.NameNotFoundException; remaining name 'env/jdbc/myDB'
  </code></pre>
  
  <p>When I start up Jetty with debugging enabled, it looks like it's registering the name and everything, although I'm far from being a Jetty expert.  Did I miss a step here? What's left?</p>