title: Tomcat is unable to read my context.xml file
body: <p>I have the following issue:
  I have context.xml file which can not be read by the server either by adding through @Resource() injection or by using class (check below). I'm using eclipse, Tomcat 9.0. I have .war file exported by eclipse and put in the target folder within my project. Here goes the code.</p>
  
  <p>Context.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE xml&gt;
  &lt;Context path="jdbc/ParkingSystem"&gt;
      &lt;Resource name="sql2226123" 
          auth="Container" type="javax.sql.DataSource"
          maxActive="20" maxIdle="5" maxWait="10000"
          username="sql2226123" password="abcdefgh" 
          driverClassName="com.mysql.jdbc.Driver"
          url="jdbc:mysql://sql2.freemysqlhosting.net:3306/sql2226123"/&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <p><a href="https://pastebin.com/fSZG2bJR" rel="nofollow noreferrer">https://pastebin.com/fSZG2bJR</a></p>
  
  <p>and I have following class to set connection with MySQL DB here goes the constructor:
  <a href="https://pastebin.com/XKmBRAZX" rel="nofollow noreferrer">https://pastebin.com/XKmBRAZX</a></p>
  
  <p>here is constructor used in servlet:
  <a href="https://pastebin.com/EmSzL5Y1" rel="nofollow noreferrer">https://pastebin.com/EmSzL5Y1</a></p>
  
  <p>here is my pom.xml:
  <a href="https://pastebin.com/umU6R2KF" rel="nofollow noreferrer">https://pastebin.com/umU6R2KF</a></p>
  
  <p>my context.xml is located:
  C:\Users\lukas\eclipse-workspace\ParkingBookSystem\src\main\resources\META-INF\context.xml</p>
  
  <p>my .war file (exported by eclipse) is located:
  C:\Users\userName\eclipse-workspace\ProjectName\ProjectName.war</p>
  
  <p>and this is my error:
  <a href="https://i.stack.imgur.com/eUryW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eUryW.png" alt="enter image description here"></a></p>
  
  <p>I've lost all ideas :(</p>
  
  <p>Ok so I've made updates according to apache.org/tomcat-9.0
  Now my web.xml looks like this:</p>
  
  <pre><code>&lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
  http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
  version="2.4"&gt;
  &lt;description&gt;ParkingBookSystem&lt;/description&gt;
  &lt;resource-ref&gt;
      &lt;description&gt;DB Connection&lt;/description&gt;
      &lt;res-ref-name&gt;/ParkingBookSystem&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;
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.html&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>and my context.xml looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE xml&gt;
  &lt;Context&gt;
  &lt;Resource 
      name="/ParkingBookSystem" 
      auth="Container"
      type="javax.sql.DataSource"
      maxTotal="20"
      maxIdle="5"
      maxWaitMillis="10000"
      username="sql2226123"
      password="xxxxxxxx"
      driverClassName="com.mysql.jdbc.Driver"
      url="jdbc:mysql://sql2.freemysqlhosting.net:3306/sql2226123"
  /&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <p>Now the error is gone but there is only white screen displayed as if there was no connection to the MySQL DB although I'm 100% sure those:
  username="sql2226123" password="abcdefgh" 
  url="jdbc:mysql://sql2.freemysqlhosting.net:3306/sql2226123"</p>
  
  <p>are correct I logged in to the DB as admin right now with it (I've changed the password in the question on stack).</p>
  
  <p>Ok so since HTTP 500 error is gone and on web-browser now I have just white screen and Tomcat server is throwing following error so I'am adding the most acutal error:
  java.sql.SQLException: Cannot create JDBC driver of class '' for connect URL 'null'
      at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2224)
      at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createDataSource(BasicDataSource.java:2104)
      at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.getConnection(BasicDataSource.java:1563)
      at com.pbs.web.jdbc.ParkingBookSystem.BookDbUtil.doesBookExist(BookDbUtil.java:91)
      at com.pbs.web.jdbc.ParkingBookSystem.BookControllerServlet.addBook(BookControllerServlet.java:117)
      at com.pbs.web.jdbc.ParkingBookSystem.BookControllerServlet.doGet(BookControllerServlet.java:70)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
      at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:668)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
      at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
      at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:770)
      at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
      at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      at java.lang.Thread.run(Unknown Source)
  Caused by: java.sql.SQLException: No suitable driver
      at java.sql.DriverManager.getDriver(Unknown Source)
      at org.apache.tomcat.dbcp.dbcp2.BasicDataSource.createConnectionFactory(BasicDataSource.java:2209)
      ... 29 more</p>