title: JDBC Cannot load Factory Class for Data Source
body: <p>I have been having this problem for days and have not managed to fix it.  I am using tomcat 7.0 and I am completely unable to get a mysql database connection going.  The application I am writing is a jsp dynamic website using the eclipse IDE.  I get this error when TomCat 7 starts up:</p>
  
  <pre><code>WARNING: Failed to register in JMX: javax.naming.NamingException: Could not load resource factory class [Root exception is java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool.DataSourceFactory]
  </code></pre>
  
  <p>I also get this error:</p>
  
  <pre><code>javax.naming.NamingException: Could not load resource factory class [Root exception is java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool.DataSourceFactory]
      at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:84)
      at javax.naming.spi.NamingManager.getObjectInstance(Unknown Source)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:826)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:145)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:814)
      at org.apache.naming.NamingContext.lookup(NamingContext.java:159)
      at org.apache.naming.SelectorContext.lookup(SelectorContext.java:158)
      at javax.naming.InitialContext.lookup(Unknown Source)
      at test.General.Database.getConnection(Database.java:21)
      at test.Controller.LoginServlet.doPost(LoginServlet.java:43)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
      at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
      at java.lang.Thread.run(Unknown Source)
  Caused by: java.lang.ClassNotFoundException: org.apache.tomcat.jdbc.pool.DataSourceFactory
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1676)
      at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1521)
      at org.apache.naming.factory.ResourceFactory.getObjectInstance(ResourceFactory.java:82)
      ... 31 more
  </code></pre>
  
  <p>when I get to this code:</p>
  
  <pre><code>  try {
          Context ctx = new InitialContext();
          ds = (DataSource)ctx.lookup("java:comp/env/jdbc/chitchat");
        } catch (NamingException e) {
          e.printStackTrace();
        }
  </code></pre>
  
  <p>Anyone have any ideas what my problem is?  I've had this for quite literally days now and I really want to move on from this.</p>