oracle - 启动Grails应用程序时无法创建池的初始连接

标签 oracle grails

我正在使用Oracle 11g。在开发模式下启动Grails应用程序时出现以下错误。我的DataSource.Groovy列在下面。请指教。

    Error |
    2014-12-25 18:42:11,836 [localhost-startStop-1] ERROR pool.ConnectionPool  - Unable to create initia
    l connections of pool.
    Message: oracle.jdbc.driver.OracleDriver

dataSource {
    pooled = true
    jmxExport = true
    driverClassName = "oracle.jdbc.driver.OracleDriver"
    username = "john"
    password = "password"
}

更新:
我在Build.Groovy中有以下一行。但是该应用无法启动。所以我删除了它。我还需要插件吗?如果是这样,那应该是什么?
runtime ":com.oracle:ojdbc6:11.2.0.1.0"

更新-2

在我运行grails编译--refresh-dependencies并启动应用程序之后,现在出现以下错误。
Error |
2014-12-25 19:30:22,069 [localhost-startStop-1] ERROR context.GrailsContextLoaderListener  - Error i
nitializing the application: Error creating bean with name 'transactionManagerPostProcessor': Initia
lization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException
: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessionFacto
ry' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.fact
ory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve reference
to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springframewo
rk.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve r
eference to bean 'dataSourceLazy' while setting constructor argument; nested exception is org.spring
framework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceLazy': Canno
t resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested excepti
on is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSo
urceUnproxied': Error setting property values; nested exception is org.springframework.beans.Propert
yBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClas
sName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC dri
ver class [oracle.jdbc.driver.OracleDriver]
Message: Error creating bean with name 'transactionManagerPostProcessor': Initialization of bean fai
led; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bea
n with name 'transactionManager': Cannot resolve reference to bean 'sessionFactory' while setting be
an property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationExce
ption: Error creating bean with name 'sessionFactory': Cannot resolve reference to bean 'dataSource'
 while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.Bea
nCreationException: Error creating bean with name 'dataSource': Cannot resolve reference to bean 'da
taSourceLazy' while setting constructor argument; nested exception is org.springframework.beans.fact
ory.BeanCreationException: Error creating bean with name 'dataSourceLazy': Cannot resolve reference
to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.springfram
ework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Erro
r setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateExceptio
n; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClas
sName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC dri
ver class [oracle.jdbc.driver.OracleDriver]
    Line | Method
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | 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 'sessionFact
ory': Cannot resolve reference to bean 'dataSource' while setting bean property 'dataSource'; nested
 exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name
 'dataSource': Cannot resolve reference to bean 'dataSourceLazy' while setting constructor argument;
 nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean wi
th name 'dataSourceLazy': Cannot resolve reference to bean 'dataSourceUnproxied' while setting const
ructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'dataSourceUnproxied': Error setting property values; nested exception is or
g.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClas
sName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC dri
ver class [oracle.jdbc.driver.OracleDriver]
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve refe
rence to bean 'dataSource' while setting bean property 'dataSource'; nested exception is org.springf
ramework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource': Cannot res
olve reference to bean 'dataSourceLazy' while setting constructor argument; nested exception is org.
springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceLazy':
 Cannot resolve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested e
xception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '
dataSourceUnproxied': Error setting property values; nested exception is org.springframework.beans.P
ropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClas
sName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC dri
ver class [oracle.jdbc.driver.OracleDriver]
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'dataSource': Cannot resolve referenc
e to bean 'dataSourceLazy' while setting constructor argument; nested exception is org.springframewo
rk.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceLazy': Cannot resol
ve reference to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is o
rg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnp
roxied': Error setting property values; nested exception is org.springframework.beans.PropertyBatchU
pdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClas
sName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC dri
ver class [oracle.jdbc.driver.OracleDriver]
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'dataSourceLazy': Cannot resolve refe
rence to bean 'dataSourceUnproxied' while setting constructor argument; nested exception is org.spri
ngframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceUnproxied'
: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateEx
ception; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClas
sName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC dri
ver class [oracle.jdbc.driver.OracleDriver]
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
Caused by BeanCreationException: Error creating bean with name 'dataSourceUnproxied': Error setting
property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property 'driverClas
sName' threw exception; nested exception is java.lang.IllegalStateException: Could not load JDBC dri
ver class [oracle.jdbc.driver.OracleDriver]
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
Caused by PropertyBatchUpdateException: Failed properties: Property 'driverClassName' threw exceptio
n; nested exception is java.lang.IllegalStateException: Could not load JDBC driver class [oracle.jdb
c.driver.OracleDriver]
->>  262 | run       in java.util.concurrent.FutureTask
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    744 | run       in java.lang.Thread
| Error Forked Grails VM exited with error

最佳答案

找不到带有JDBC驱动程序的Oracle jar。将文件放在grails项目的lib目录中。

将jar文件放在lib目录中时,不会自动发现该文件。跑

grails compile --refresh-dependencies

然后Grails会找到jar并将其添加到依赖项和类路径中。

关于oracle - 启动Grails应用程序时无法创建池的初始连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27651705/

相关文章:

sql - Grails过滤器统计信息插入效果

sql - oracle sql查询时间段集合的并集

sql - "table that is a parent of a referential integrity constraint"对于 oracle SQL 有什么作用?

java - NullPointerException 只有在我为 GoogleCredential 对象设置了 setServiceAccountUser() 之后 (Grails/Java)

grails - Grails,当rejectIfNoRule = true时无限循环

apache - 如何使用Apache Camel 删除Grails中的大文件

security - 使用类似密码的单个 htpasswd 保护开发 Grails 应用程序

java - 如何在 Oracle 数据库中存储 Java 字节数组?

oracle - 将 CLOB 字段转储到文件中?

oracle - 如何从两个字符串列中创建表名?