title: PostgreSQL (weird): NoClassDefFoundError: com/mysql/jdbc/StringUtils
body: <p>I am getting well-known NoClassDefFoundError: com/mysql/jdbc/StringUtils, but my case is little different: I am not using MySQL at all.</p>
  
  <p>I'm working with PostgreSQL 9.1 database using JDK 1.6. 
  On my computer everything works perfectly (PostgreSQL driver is loaded, no classpath issues etc.), but I have to upload my project to my University's servers, where I am getting the following error:</p>
  
  <pre><code>java.lang.NoClassDefFoundError: Could not initialize class com.mysql.jdbc.StringUtils
  </code></pre>
  
  <p>Here is a full stack trace:</p>
  
  <pre><code>com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:286)
  java.sql.DriverManager.getConnection(DriverManager.java:582)
  java.sql.DriverManager.getConnection(DriverManager.java:185)
  elections.ConnectionManager.getConnection(ConnectionManager.java:29)
  elections.daos.LoginDAO.login(LoginDAO.java:23) 
  elections.controllers.LoginController.doPost(LoginController.java:46) 
  javax.servlet.http.HttpServlet.service(HttpServlet.java:641) 
  javax.servlet.http.HttpServlet.service(HttpServlet.java:722) 
  sun.reflect.GeneratedMethodAccessor35.invoke(Unknown Source) 
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 
  java.lang.reflect.Method.invoke(Method.java:597) 
  org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:274) 
  org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:271) 
  java.security.AccessController.doPrivileged(Native Method) 
  javax.security.auth.Subject.doAsPrivileged(Subject.java:517) 
  org.apache.catalina.security.SecurityUtil.execute(SecurityUtil.java:306) 
  org.apache.catalina.security.SecurityUtil.doAsPrivilege(SecurityUtil.java:166)
  org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:299) 
  org.apache.catalina.core.ApplicationFilterChain.access$000(ApplicationFilterChain.java:57) 
  org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:193) 
  org.apache.catalina.core.ApplicationFilterChain$1.run(ApplicationFilterChain.java:189) 
  java.security.AccessController.doPrivileged(Native Method) 
  org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188) 
  org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:208) 
  org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) 
  org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) 
  org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168) 
  org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98) 
  org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927) 
  org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) 
  org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407) 
  org.apache.coyote.ajp.AjpAprProcessor.process(AjpAprProcessor.java:197) 
  org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:579) 
  org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1770) 
  java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
  java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
  java.lang.Thread.run(Thread.java:662)
  </code></pre>
  
  <p>Here's my class which provides connection (It's my first JDBC project; I know that code below is not threadsafe; I'm going to rewrite it using Connection Pooling, but first I need to get it to work...)</p>
  
  <pre><code>static Connection conn;
  
  public static Connection getConnection() throws Exception {
      try {
  
          String url = "jdbc:postgresql://host/database";
          String username = "username";
          String pwd = "password";
  
          Class.forName("org.postgresql.Driver");
  
          try {
              conn = DriverManager.getConnection(url, username, pwd);
          } catch (SQLException e) {
              e.printStackTrace();
              throw e;
          }
      } catch (ClassNotFoundException e) {
          throw e;
      }
      return conn;
  }
  </code></pre>
  
  <p>I did huge search on the internet but I seem to be the only man in the world with such issue... Everybody else has this problem with MySQL only.</p>
  
  <p>I have even tried to put MySQL driver (containing the lacking com.mysql.jdbc.StringUtils class) into WEB-INF/lib folder, but this didn't help.</p>
  
  <p>Only useful information I have found is that probably error is hidden somewhere else (that means, some class that com.mysql.jdbc.StringUtils depends on couldn;t be loaded), but I don't know where to search. </p>
  
  <p>I really don't understand why MySQL classes are searched for, while I use PostgreSQL only.</p>
  
  <p>Any kind of help would be appreciated! :)</p>