title: Cannot load JDBC driver class 'com.mysql.cj.jdbc.driver'
body: <p>I am a Spring MVC beginner using Tomcat 9 with Eclipse to run a spring application. I receive the following error at run time.</p>
  
  <pre><code>org.apache.jasper.JasperException: An exception occurred processing JSP page [/WEB-INF/views/listOrganization1.jsp] at line [13]
  
      10: &lt;/head&gt;
      11: &lt;body&gt;
      12:     &lt;h1&gt;Listing organizations using JSTL SQL tag&lt;/h1&gt;
      13:     &lt;sql:query var="rs" dataSource="jdbc/springdb"&gt;
      14:         SELECT * FROM organization
      15:     &lt;/sql:query&gt;
      16:     
  
  
      Stacktrace:
          org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:588)
          org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:466)
          org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
          org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
          org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
          org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:170)
          org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:314)
          org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325)
          org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069)
          org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008)
          org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
          org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
          org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:870)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
          org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
          org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  
  
      Root Cause
      javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Cannot load JDBC driver class 'com.mysql.cj.jdbc.driver'"
          org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:669)
          org.apache.jsp.WEB_002dINF.views.listOrganization1_jsp._jspService(listOrganization1_jsp.java:156)
          org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
          org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
          org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
          org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
          org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
          org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:170)
          org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:314)
          org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325)
          org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069)
          org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008)
          org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
          org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
          org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:870)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
          org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
          org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  
  
      Root Cause
      javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Cannot load JDBC driver class 'com.mysql.cj.jdbc.driver'"
          org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:285)
          org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:168)
          org.apache.jsp.WEB_002dINF.views.listOrganization1_jsp._jspx_meth_sql_005fquery_005f0(listOrganization1_jsp.java:180)
          org.apache.jsp.WEB_002dINF.views.listOrganization1_jsp._jspService(listOrganization1_jsp.java:135)
          org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
          org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)
          org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)
          org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
          org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
          org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:170)
          org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:314)
          org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1325)
          org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1069)
          org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1008)
          org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925)
          org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:978)
          org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:870)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:635)
          org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:855)
          javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
          org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  </code></pre>
  
  <p>But <code>mysql-connector-java-6.0.6.jar</code> already exists in the project as a Maven dependency</p>
  
  <p><a href="https://i.stack.imgur.com/kBOv2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kBOv2.png" alt="enter image description here"></a></p>
  
  <p>And context.xml has for the Tomcat already has the database information as a resource</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!--
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
    this work for additional information regarding copyright ownership.
    The ASF licenses this file to You under the Apache License, Version 2.0
    (the "License"); you may not use this file except in compliance with
    the License.  You may obtain a copy of the License at
  
        http://www.apache.org/licenses/LICENSE-2.0
  
    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
  --&gt;&lt;!-- The contents of this file will be loaded for each web application --&gt;&lt;Context&gt;
  
      &lt;!-- Default set of monitored resources. If one of these changes, the    --&gt;
      &lt;!-- web application will be reloaded.                                   --&gt;
      &lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;
      &lt;WatchedResource&gt;${catalina.base}/conf/web.xml&lt;/WatchedResource&gt;
  
      &lt;!-- Uncomment this to disable session persistence across Tomcat restarts --&gt;
      &lt;!--
      &lt;Manager pathname="" /&gt;
      --&gt;
  
      &lt;Resource name="jdbc/springdb" auth="Container" type="javax.sql.DataSource"
                 maxTotal="100" maxIdle="30" maxWaitMillis="10000"
                 username="devuser" password="$Data4Dev" driverClassName="com.mysql.cj.jdbc.driver"
                 url="jdbc:mysql://localhost:3306/spring_db?useSSL=false"/&gt;
  
  &lt;/Context&gt;
  </code></pre>
  
  <p>As per the response to another question here, I have also added mysql-connector jar to the run time configuration of the Tomcat 9 server.
  <a href="https://i.stack.imgur.com/qb7Wa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qb7Wa.png" alt="enter image description here"></a></p>
  
  <p>I also deleted the repositories in C:\Users\user1.m2\repository multiple times, closed and opened Eclipse and updated Maven for project - nothing has worked and I keep getting the same error.</p>