title: NoClassDefFoundError: com/mysql/jdbc/StringUtils Tomcat 6
body: <p>So essentially I am using maven to organize my project in the same way I have always done, but I am getting an error in catalina.out telling me that it cannot find the StringUtils class in com.mysql.jdbc even though I can see that the jar is in the war classpath. I have not had the same problem with Tomcat7 on a different server leading me to believe that there is a library class somewhere obscuring the jar file I have in the actual project. Here is the exception:</p>
  
  <p>Caused by: java.lang.NoClassDefFoundError: com/mysql/jdbc/StringUtils</p>
  
  <p>My maven dependency is as follows:</p>
  
  <pre><code>&lt;dependency&gt;
              &lt;groupId&gt;mysql&lt;/groupId&gt;
              &lt;artifactId&gt;mysql-connector-java&lt;/artifactId&gt;
              &lt;version&gt;5.1.20&lt;/version&gt;
          &lt;/dependency&gt;
  </code></pre>
  
  <p>I just cannot fathom how the class is not found in the classpath when I can see the jar in the lib part of WEB-INF and I can see the class in the jar. Does anybody have an idea on what could be happening here? Thanks for any help.</p>
  
  <p>If you need more information just let me know.</p>
  
  <p>Full Stacktrace: (I use Apache's BasicDataSource).</p>
  
  <pre><code>    Throwable occurred: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'voiceManager' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.voiceforge.api.swift.VoiceManager]: Constructor threw exception; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:mysql://localhost/vf2?autoReconnect=true'
      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:288)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
      at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
      at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384)
      at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283)
      at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111)
      at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3843)
      at org.apache.catalina.core.StandardContext.start(StandardContext.java:4338)
      at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
      at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
      at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
      at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:882)
      at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:522)
      at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1283)
      at sun.reflect.GeneratedMethodAccessor66.invoke(Unknown Source)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
      at java.lang.reflect.Method.invoke(Method.java:611)
      at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:297)
      at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:848)
      at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:773)
      at org.apache.catalina.manager.ManagerServlet.check(ManagerServlet.java:1471)
      at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.java:250)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.filters.CsrfPreventionFilter.doFilter(CsrfPreventionFilter.java:186)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:530)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
      at java.lang.Thread.run(Thread.java:736)
  Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.voiceforge.api.swift.VoiceManager]: Constructor threw exception; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:mysql://localhost/vf2?autoReconnect=true'
      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
      at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:110)
      at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:280)
      ... 48 more
  Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:mysql://localhost/vf2?autoReconnect=true'
      at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:80)
      at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:382)
      at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:456)
      at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:464)
      at com.voiceforge.api.dao.VoiceforgeDaoImpl.getVoiceList(VoiceforgeDaoImpl.java:86)
      at com.voiceforge.api.swift.VoiceManager.refreshVoices(VoiceManager.java:33)
      at com.voiceforge.api.swift.VoiceManager.&lt;init&gt;(VoiceManager.java:23)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:56)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:39)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:527)
      at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
      ... 50 more
  Caused by: org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'com.mysql.jdbc.Driver' for connect URL 'jdbc:mysql://localhost/vf2?autoReconnect=true'
      at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
      at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
      at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
      at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
      at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
      ... 61 more
  Caused by: java.lang.NoClassDefFoundError: com/mysql/jdbc/StringUtils
      at com.mysql.jdbc.NonRegisteringDriver.parseURL(NonRegisteringDriver.java:582)
      at com.mysql.jdbc.NonRegisteringDriver.acceptsURL(NonRegisteringDriver.java:236)
      at java.sql.DriverManager.getDriver(DriverManager.java:443)
      at org.apache.commons.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
      ... 65 more
  </code></pre>