title: Can't access to Embedded Derby in Tomcat 8
body: <p>I have a restful api-implementation running in a Tomcat 8 server. I decided to use the embedded Derby version to store data in a database via JDBC (using Eclipse). From my point of view, the official tutorial for the embedded version wasn't very helpfull. I followed the steps here:
  <a href="http://www.nailedtothex.org/roller/kyle/entry/defining-embedded-derby-as-a" rel="nofollow noreferrer">http://www.nailedtothex.org/roller/kyle/entry/defining-embedded-derby-as-a</a></p>
  
  <p>My problem is, that the connection to Derby is not found and since I am using the embedded version for Derby, I don't know how to debug the reason for not connecting to Derby.</p>
  
  <p>I copied the derby.jar and derby-shutdown-listener.jar into the lib folder of my Tomcat server. I adapeted the context.xml and the server.xml. </p>
  
  <p>context.xml:</p>
  
  <pre><code>&lt;Context docBase="myapp"
        path="/myapp"
        reloadable="true"&gt;
  
        &lt;ResourceLink name="jdbc/derby"
                global="jdbc/derby"
                type="javax.sql.DataSource" /&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <p>I also tried this version of the context.xml:</p>
  
  <pre><code>&lt;Context docBase="myapp"
        path="/myapp"
        reloadable="true"&gt;
  &lt;Resource name="jdbc/derby" auth="Container"
        driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
        username="bot" password="carmeq!"
        type="javax.sql.DataSource"
        url="jdbc:derby:mydb;create=true"/&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <p>server.xml:</p>
  
  <pre><code> &lt;Listener className="org.nailedtothex.derby.DerbyShutdownLifecycleListener" /&gt;
  </code></pre>
  
  <p>And I changed my web.xml:</p>
  
  <pre><code>   &lt;resource-ref&gt;
      &lt;res-ref-name&gt;jdbc/derby&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>In my Java class concerning the connection to the db, I have the following specification:</p>
  
  <pre><code>String dbURL2 = "jdbc:derby:mydb;create=true";
  </code></pre>
  
  <p>That is my exception I am receiving when I call my restful function.</p>
  
  <pre><code>javax.servlet.ServletException: java.lang.NullPointerException
      org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:487)
      org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:425)
      org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:383)
      org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:336)
      org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:223)
      org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
  </code></pre>
  
  <p>When debugging the code, it shows that no suitable driver for the specified url was found.</p>
  
  <p>Moreover, I am using Maven and beside the derby.jar in my Tomcat folder (showing up under Libraries/Apache Tomcat v8.0), I also added the same derby.jar (Version 10.9.1.0) in my pom.xml.</p>
  
  <p>Thanks</p>