title: DB2 driver not found with Tomcat CP but Commons works fine?
body: <p>I'm using tomcat + spring. When use following config:</p>
  
  <pre><code>&lt;bean id="dataSource" class="org.apache.tomcat.dbcp.dbcp.BasicDataSource"&gt;
      &lt;property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" /&gt;
      &lt;property name="url" value="url" /&gt;
      &lt;property name="username" value="user" /&gt;
      &lt;property name="password" value="pass" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I'm able to obtain connection. But when I try use Tomcat's CP as follows:</p>
  
  <pre><code>&lt;bean id="dataSource" class="org.apache.tomcat.jdbc.pool.DataSource"&gt;
      &lt;property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" /&gt;
      &lt;property name="url" value="url" /&gt;
      &lt;property name="username" value="user" /&gt;
      &lt;property name="password" value="pass" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I got nested root cause exception: <code>java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver</code></p>
  
  <p>The only change I'm making is rename class which is responsible for creating data source. Why this happen? How to solve that?</p>
  
  <p><strong>UPDATE - STACK TRACE</strong></p>
  
  <pre><code>exception
  
  org.springframework.web.util.NestedServletException: Request processing failed; nested exception is java.sql.SQLException: com.ibm.db2.jcc.DB2Driver
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
  root cause
  
  java.sql.SQLException: com.ibm.db2.jcc.DB2Driver
      org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:254)
      org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
      org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:702)
      org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:634)
      org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:488)
      org.apache.tomcat.jdbc.pool.ConnectionPool.&lt;init&gt;(ConnectionPool.java:144)
      org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116)
      org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:103)
      org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:127)
      spring.controller.ReviewController.getReviewById(ReviewController.java:25)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      java.lang.reflect.Method.invoke(Method.java:606)
      org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
      org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
      org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
      org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
      org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690)
      org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
  root cause
  
  java.lang.ClassNotFoundException: com.ibm.db2.jcc.DB2Driver
      java.net.URLClassLoader$1.run(URLClassLoader.java:366)
      java.net.URLClassLoader$1.run(URLClassLoader.java:355)
      java.security.AccessController.doPrivileged(Native Method)
      java.net.URLClassLoader.findClass(URLClassLoader.java:354)
      java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      java.lang.Class.forName0(Native Method)
      java.lang.Class.forName(Class.java:270)
      org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:246)
      org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
      org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:702)
      org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:634)
      org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:488)
      org.apache.tomcat.jdbc.pool.ConnectionPool.&lt;init&gt;(ConnectionPool.java:144)
      org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:116)
      org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:103)
      org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:127)
      spring.controller.ReviewController.getReviewById(ReviewController.java:25)
      sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      java.lang.reflect.Method.invoke(Method.java:606)
      org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:215)
      org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:132)
      org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
      org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:749)
      org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:690)
      org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:83)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:945)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:876)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:852)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:108)
  </code></pre>