title: java.lang.ClassNotFoundException: org.postgresql.Driver whilte trying to connect from spring
body: <p>I'm trying to connect to a postgresql DB from a java aplication developed on Spring.</p>
  
  <p>The odd thing is that if I ran it as a java aplication, it works fine. </p>
  
  <p>When you try to run it on the server it trows an exception</p>
  
  <blockquote>
    <p>java.lang.ClassNotFoundException: org.postgresql.Driver
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1305)
        at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1157)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at com.CBTD.database.BaseDeDatos.establecerConexion(BaseDeDatos.java:31)
    ....</p>
  </blockquote>
  
  <p>Is there any incompatibility between Spring (STS) and postgresql?</p>
  
  <p>The controller code:</p>
  
  <pre><code>@RequestMapping(value = "/inicio", method = RequestMethod.GET)
  public String ObtenerUsuario(@RequestParam(required=true) String user, @RequestParam(required=true) String pass){
  
      LoginExpert login = new LoginExpert();
      if (login.validarUsuario(user, pass)){
          return "inicio";
      }else{
          return "login";
      }
  
  }
  </code></pre>
  
  <p>An intermediate class</p>
  
  <pre><code>public boolean validarUsuario(String user, String pass){
  
      TablaUsuario tu = new TablaUsuario();
      Usuario us = new Usuario();
      try {
          us = tu.buscarUsuario(user);
      } catch (SQLException e) {
          e.printStackTrace();
      }
      return (us.getContrasena().equals(pass));
  
  }
  </code></pre>
  
  <p>The class where I access the DB (this part running as a java app works fine)</p>
  
  <pre><code>public Usuario buscarUsuario(String nombre) throws SQLException{
  
      String sql = "SELECT * from usuario WHERE nombre_usuario = '"+nombre+"'";
  
      BaseDeDatos.getInstancia().establecerConexion();
      ResultSet rs = BaseDeDatos.getInstancia().ejecutarQuery(sql);
  
      Usuario us= new Usuario();
      while(rs.next()){
          us.setNombreUsuario(rs.getObject(2).toString());
          us.setContrasena(rs.getObject(3).toString());
          us.setActivo(rs.getBoolean(4));
      }
  
  
      BaseDeDatos.getInstancia().cerrarConexion();
  
      return us;
  
  }
  </code></pre>