Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Grails War无法部署到Tomcat-错误:找不到org.postgresql.Driver_Java_Grails_Tomcat7_War_Postgresql 9.3 - Fatal编程技术网

Java Grails War无法部署到Tomcat-错误:找不到org.postgresql.Driver

Java Grails War无法部署到Tomcat-错误:找不到org.postgresql.Driver,java,grails,tomcat7,war,postgresql-9.3,Java,Grails,Tomcat7,War,Postgresql 9.3,我有一个使用PostgreSQL的grails应用程序。当我将grails控制台用作: 重新运行程序 grails测试应用程序 圣杯清洁 圣杯战争 grails编译 在BuildConfig中,我有: dependencies { runtime 'org.postgresql:postgresql:9.3-1100-jdbc41' } 但当我尝试打包.war文件时,将该文件复制到部署Tomcat应用程序的$CATALINA_HOME/webapps/中,并通过以下方式启动Tomcat

我有一个使用PostgreSQL的grails应用程序。当我将grails控制台用作: 重新运行程序 grails测试应用程序 圣杯清洁 圣杯战争 grails编译

在BuildConfig中,我有:

dependencies {
    runtime 'org.postgresql:postgresql:9.3-1100-jdbc41'
}
但当我尝试打包.war文件时,将该文件复制到部署Tomcat应用程序的$CATALINA_HOME/webapps/中,并通过以下方式启动Tomcat服务器:CATALINA.sh start。我在tracktrace.log中收到错误消息:

21-Mar-2014 14:45:57.701 SEVERE [localhost-startStop-1] org.apache.tomcat.jdbc.pool.ConnectionPool.init Unable to create initial connections of pool.
java.sql.SQLException: org.postgresql.Driver
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:253)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:181)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:699)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:633)
at org.apache.tomcat.jdbc.pool.ConnectionPool.init(ConnectionPool.java:484)
at org.apache.tomcat.jdbc.pool.ConnectionPool.<init>(ConnectionPool.java:142)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.pCreatePool(DataSourceProxy.java:115)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.createPool(DataSourceProxy.java:102)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:126)

我不知道这是怎么回事。有人可以帮我吗?

将JDBC驱动程序JAR移动到Tomcat的/lib目录。

不仅要移动库和JAR文件,还要确保数据源设置正确,如下所示:
当然没错!因为它是在使用grails命令时运行的。但我找到了解决方案,我需要将数据库驱动程序库处理到web服务器的lib文件夹,例如:tomcat。如果你的问题得到了回答,请接受。
....
postgresql-9.3-1100-jdbc41.jar
....
dependencies {
        runtime "postgresql:postgresql:9.1-901.jdbc4"
    }

dataSource {
    pooled = true
    driverClassName = "org.postgresql.Driver"
    dialect = "org.hibernate.dialect.PostgreSQLDialect"
    username = "iqbal"
    password = ""
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory' // Hibernate 3
//    cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' // Hibernate 4
}

// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
            url = "jdbc:postgresql://localhost:5432/seram"
        }
    }
    test {
        dataSource {
            dbCreate = "update"
            url = "jdbc:postgresql://localhost:5432/seram"
        }
    }
    production {
        dataSource {
            dbCreate = "update"
            url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
            properties {
                maxActive = -1
                minEvictableIdleTimeMillis=1800000
                timeBetweenEvictionRunsMillis=1800000
                numTestsPerEvictionRun=3
                testOnBorrow=true
                testWhileIdle=true
                testOnReturn=false
                validationQuery="SELECT 1"
                jdbcInterceptors="ConnectionState"
            }
        }
    }
}