title: how to config postgresql to grails application
body: <p>I am trying to configure PostgreSQL in a grails application, and I added the <code>postgresql-9.1-902.jdbc4.jar</code> file to grails app lib folder,and  after that I add <code>runtime 'postgresql:postgresql:9.1-902.jdbc4'</code> dependencies block in <code>BuildConfig.groovy</code>. I am trying to run the application through <code>run-app</code>, but it is showing the following error:</p>
  
  <pre><code>| Loading Grails 2.0.1
  | Configuring classpath.
  | Environment set to development.....
  | Packaging Grails application.....
  | Compiling 1 source files.....
  | Running Grails application
  | Error 2012-07-18 11:29:47,573 [pool-7-thread-1] ERROR context.GrailsContextLoader  - Error executing bootstraps: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgres://localhost:5432/empapp'
  Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgres://localhost:5432/empapp'
     Line | Method
  -&gt;&gt; 303 | innerRun in java.util.concurrent.FutureTask$Sync
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |   138 | run      in java.util.concurrent.FutureTask
  |   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
  |   908 | run      in     ''
  ^   662 | run . .  in java.lang.Thread
  Caused by BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgres://localhost:5432/empapp'
  -&gt;&gt; 303 | innerRun in java.util.concurrent.FutureTask$Sync
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |   138 | run      in java.util.concurrent.FutureTask
  |   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
  |   908 | run      in     ''
  ^   662 | run . .  in java.lang.Thread
  Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgres://localhost:5432/empapp'
  -&gt;&gt; 303 | innerRun in java.util.concurrent.FutureTask$Sync
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |   138 | run      in java.util.concurrent.FutureTask
  |   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
  |   908 | run      in     ''
  ^   662 | run . .  in java.lang.Thread
  Caused by BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgres://localhost:5432/empapp'
  -&gt;&gt; 303 | innerRun in java.util.concurrent.FutureTask$Sync
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |   138 | run      in java.util.concurrent.FutureTask
  |   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
  |   908 | run      in     ''
  ^   662 | run . .  in java.lang.Thread
  Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgres://localhost:5432/empapp'
  -&gt;&gt; 303 | innerRun in java.util.concurrent.FutureTask$Sync
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |   138 | run      in java.util.concurrent.FutureTask
  |   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
  |   908 | run      in     ''
  ^   662 | run . .  in java.lang.Thread
  Caused by SQLNestedException: Cannot create JDBC driver of class 'org.postgresql.Driver' for connect URL 'jdbc:postgres://localhost:5432/empapp'
  -&gt;&gt; 1452 | createConnectionFactory in org.apache.commons.dbcp.BasicDataSource
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |   1371 | createDataSource in     ''
  |   1044 | getConnection in     ''
  |   303 | innerRun in java.util.concurrent.FutureTask$Sync
  |   138 | run . .  in java.util.concurrent.FutureTask
  |   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
  |   908 | run . .  in     ''
  ^   662 | run      in java.lang.Thread
  Caused by SQLException: No suitable driver
  -&gt;&gt; 264 | getDriver in java.sql.DriverManager
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
  |   1437 | createConnectionFactory in org.apache.commons.dbcp.BasicDataSource
  |   1371 | createDataSource in     ''
  |   1044 | getConnection in     ''
  |   303 | innerRun in java.util.concurrent.FutureTask$Sync
  |   138 | run      in java.util.concurrent.FutureTask
  |   886 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
  |   908 | run      in     ''
  ^   662 | run . .  in java.lang.Thread
  </code></pre>
  
  <p>This is my <code>datasource.groovy</code> file:</p>
  
  <pre><code>dataSource {
        pooled = true
      driverClassName = "org.postgresql.Driver"
      dialect = org.hibernate.dialect.PostgreSQLDialect
      username = "postgres"
      password = "password"
  }
  hibernate {
      cache.use_second_level_cache = true
      cache.use_query_cache = true
      cache.provider_class='org.hibernate.cache.EhCacheProvider'
  }
  // environment specific settings
  environments {
      development {
          dataSource {
              dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
                  url = "jdbc:postgres://localhost:5432/empapp"
          }
      }
      test {
          dataSource {
              dbCreate = "update"
              url = "jdbc:postgres://localhost:5432/empapp"
          }
      }
      production {
          dataSource {
              dbCreate = "update"
              url = "jdbc:postgres://localhost:5432/empapp"
              pooled = true
              properties {
                 maxActive = -1
                 minEvictableIdleTimeMillis=1800000
                 timeBetweenEvictionRunsMillis=1800000
                 numTestsPerEvictionRun=3
                 testOnBorrow=true
                 testWhileIdle=true
                 testOnReturn=true
                 validationQuery="SELECT 1"
              }
          }
      }
  }
  </code></pre>
  
  <p>Where am I going wrong?</p>