1

我在本地安装了一个 Oracle 11g XE(快速版)实例。我想让它成为适用于所有环境的 Grails DB。我有 Oracle 用户的用户名/密码,并且我的 ojdbc6.jar 文件位于此处:

\myAppName\lib\ojdbc6.jar

而且我还没有在数据库中创建任何表 - 我假设 Grails 足够聪明,可以根据需要创建表,但如果不是,那显然是一个问题......

这是我的 DataSource.groovy 文件内容:

dataSource {
    //ORACLE
    dbCreate = "create-drop"
    url = "jdbc:oracle:thin:@127.0.0.1:1521:XE"
    pooled = true
    username = "mills_gtunes"
    password = "*******"
    driverClassName = "oracle.jdbc.driver.OracleDriver"
    //          dialect= "org.hibernate.dialect.Oracle10gDialect"
    dialect= "org.hibernate.dialect.OracleDialect"

    properties {
        maxActive = -1
        minEvictableIdleTimeMillis=1800000
        timeBetweenEvictionRunsMillis=1800000
        numTestsPerEvictionRun=3
        testOnBorrow=true
        testWhileIdle=true
        testOnReturn=true
        validationQuery="SELECT 1"
    }
}


hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
    development {
        dataSource {

            //H2
            //  dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
            //  url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000"

            //ORACLE
            dbCreate = "create-drop"
            url = "jdbc:oracle:thin:@127.0.0.1:1521:XE"
            pooled = true
            username = "mills_gtunes"
            password = "******"
            driverClassName = "oracle.jdbc.driver.OracleDriver"
            dialect= "org.hibernate.dialect.OracleDialect"

            properties {
                maxActive = -1
                minEvictableIdleTimeMillis=1800000
                timeBetweenEvictionRunsMillis=1800000
                numTestsPerEvictionRun=3
                testOnBorrow=true
                testWhileIdle=true
                testOnReturn=true
                validationQuery="SELECT 1"
            }
        }
    }

这是我从 Windows 命令行运行“grails run-app”后遇到的错误:

->>   91 | newSQLException in oracle.jdbc.driver.SQLStateMapping
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    133 | newSQLException in oracle.jdbc.driver.DatabaseError
|    206 | throwSqlException in     ''
|    455 | processError in oracle.jdbc.driver.T4CTTIoer
|    413 | processError in     ''
|   1034 | receive   in oracle.jdbc.driver.T4C8Oall
|    183 | doOall8 . in oracle.jdbc.driver.T4CStatement
|    780 | executeForDescribe in     ''
|    855 | executeMaybeDescribe in     ''
|   1186 | doExecuteWithTimeout in oracle.jdbc.driver.OracleStatement
|   1377 | executeQuery in     ''
|    387 | executeQuery in oracle.jdbc.driver.OracleStatementWrapper
|    208 | executeQuery in org.apache.commons.dbcp.DelegatingStatement
|    658 | validateConnection in org.apache.commons.dbcp.PoolableConnectionFacto
ry
|   1558 | validateConnectionFactory in org.apache.commons.dbcp.BasicDataSource
|   1545 | createPoolableConnectionFactory in     ''
|   1388 | createDataSource in     ''
|   1044 | getConnection in     ''
|    334 | innerRun  in java.util.concurrent.FutureTask$Sync
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
| Error 2013-05-04 14:47:22,691 [localhost-startStop-1] ERROR context.GrailsCont
extLoader  - Error initializing Grails: Error creating bean with name 'transacti
onManagerPostProcessor': Initialization of bean failed; nested exception is org.
springframework.beans.factory.BeanCreationException: Error creating bean with na
me '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 'lobHandlerDetector' while setting bean p
roperty 'lobHandler'; nested exception is org.springframework.beans.factory.Bean
CreationException: Error creating bean with name 'lobHandlerDetector': Invocatio
n of init method failed; nested exception is org.springframework.jdbc.support.Me
taDataAccessException: Error while extracting DatabaseMetaData; nested exception
 is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnection
Factory (ORA-00923: FROM keyword not found where expected
)
Message: Error creating bean with name 'transactionManagerPostProcessor': Initia
lization of bean failed; nested exception is org.springframework.beans.factory.B
eanCreationException: Error creating bean with name 'transactionManager': Cannot
 resolve reference to bean 'sessionFactory' while setting bean property 'session
Factory'; nested exception is org.springframework.beans.factory.BeanCreationExce
ption: Error creating bean with name 'sessionFactory': Cannot resolve reference
to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested ex
ception is org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'lobHandlerDetector': Invocation of init method failed; nested
 exception is org.springframework.jdbc.support.MetaDataAccessException: Error wh
ile extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQL
NestedException: Cannot create PoolableConnectionFactory (ORA-00923: FROM keywor
d not found where expected
)
    Line | Method
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by BeanCreationException: Error creating bean with name 'transactionManag
er': Cannot resolve reference to bean 'sessionFactory' while setting bean proper
ty 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanC
reationException: 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: E
rror creating bean with name 'lobHandlerDetector': Invocation of init method fai
led; nested exception is org.springframework.jdbc.support.MetaDataAccessExceptio
n: Error while extracting DatabaseMetaData; nested exception is org.apache.commo
ns.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (ORA-00923:
FROM keyword not found where expected
)
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by BeanCreationException: Error creating bean with name 'sessionFactory':
 Cannot resolve reference to bean 'lobHandlerDetector' while setting bean proper
ty 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreat
ionException: Error creating bean with name 'lobHandlerDetector': Invocation of
init method failed; nested exception is org.springframework.jdbc.support.MetaDat
aAccessException: Error while extracting DatabaseMetaData; nested exception is o
rg.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFacto
ry (ORA-00923: FROM keyword not found where expected
)
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by BeanCreationException: Error creating bean with name 'lobHandlerDetect
or': Invocation of init method failed; nested exception is org.springframework.j
dbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; ne
sted exception is org.apache.commons.dbcp.SQLNestedException: Cannot create Pool
ableConnectionFactory (ORA-00923: FROM keyword not found where expected
)
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nest
ed exception is org.apache.commons.dbcp.SQLNestedException: Cannot create Poolab
leConnectionFactory (ORA-00923: FROM keyword not found where expected
)
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by SQLNestedException: Cannot create PoolableConnectionFactory (ORA-00923
: FROM keyword not found where expected
)
->> 1549 | createPoolableConnectionFactory in org.apache.commons.dbcp.BasicDataS
ource
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1388 | createDataSource in     ''
|   1044 | getConnection in     ''
|    334 | innerRun  in java.util.concurrent.FutureTask$Sync
|    166 | run . . . in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run       in java.lang.Thread

Caused by SQLSyntaxErrorException: ORA-00923: FROM keyword not found where expec
ted

->>   91 | newSQLException in oracle.jdbc.driver.SQLStateMapping
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    133 | newSQLException in oracle.jdbc.driver.DatabaseError
|    206 | throwSqlException in     ''
|    455 | processError in oracle.jdbc.driver.T4CTTIoer
|    413 | processError in     ''
|   1034 | receive   in oracle.jdbc.driver.T4C8Oall
|    183 | doOall8 . in oracle.jdbc.driver.T4CStatement
|    780 | executeForDescribe in     ''
|    855 | executeMaybeDescribe in     ''
|   1186 | doExecuteWithTimeout in oracle.jdbc.driver.OracleStatement
|   1377 | executeQuery in     ''
|    387 | executeQuery in oracle.jdbc.driver.OracleStatementWrapper
|    208 | executeQuery in org.apache.commons.dbcp.DelegatingStatement
|    658 | validateConnection in org.apache.commons.dbcp.PoolableConnectionFacto
ry
|   1558 | validateConnectionFactory in org.apache.commons.dbcp.BasicDataSource
|   1545 | createPoolableConnectionFactory in     ''
|   1388 | createDataSource in     ''
|   1044 | getConnection in     ''
|    334 | innerRun  in java.util.concurrent.FutureTask$Sync
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
| Error 2013-05-04 14:47:22,729 [localhost-startStop-1] ERROR [localhost].[/gTun
es]  - Exception sending context initialized event to listener instance of class
 org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener
Message: Error creating bean with name 'transactionManagerPostProcessor': Initia
lization of bean failed; nested exception is org.springframework.beans.factory.B
eanCreationException: Error creating bean with name 'transactionManager': Cannot
 resolve reference to bean 'sessionFactory' while setting bean property 'session
Factory'; nested exception is org.springframework.beans.factory.BeanCreationExce
ption: Error creating bean with name 'sessionFactory': Cannot resolve reference
to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested ex
ception is org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'lobHandlerDetector': Invocation of init method failed; nested
 exception is org.springframework.jdbc.support.MetaDataAccessException: Error wh
ile extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQL
NestedException: Cannot create PoolableConnectionFactory (ORA-00923: FROM keywor
d not found where expected
)
    Line | Method
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by BeanCreationException: Error creating bean with name 'transactionManag
er': Cannot resolve reference to bean 'sessionFactory' while setting bean proper
ty 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanC
reationException: 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: E
rror creating bean with name 'lobHandlerDetector': Invocation of init method fai
led; nested exception is org.springframework.jdbc.support.MetaDataAccessExceptio
n: Error while extracting DatabaseMetaData; nested exception is org.apache.commo
ns.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (ORA-00923:
FROM keyword not found where expected
)
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by BeanCreationException: Error creating bean with name 'sessionFactory':
 Cannot resolve reference to bean 'lobHandlerDetector' while setting bean proper
ty 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreat
ionException: Error creating bean with name 'lobHandlerDetector': Invocation of
init method failed; nested exception is org.springframework.jdbc.support.MetaDat
aAccessException: Error while extracting DatabaseMetaData; nested exception is o
rg.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFacto
ry (ORA-00923: FROM keyword not found where expected
)
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by BeanCreationException: Error creating bean with name 'lobHandlerDetect
or': Invocation of init method failed; nested exception is org.springframework.j
dbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; ne
sted exception is org.apache.commons.dbcp.SQLNestedException: Cannot create Pool
ableConnectionFactory (ORA-00923: FROM keyword not found where expected
)
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nest
ed exception is org.apache.commons.dbcp.SQLNestedException: Cannot create Poolab
leConnectionFactory (ORA-00923: FROM keyword not found where expected
)
->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread

Caused by SQLNestedException: Cannot create PoolableConnectionFactory (ORA-00923
: FROM keyword not found where expected
)
->> 1549 | createPoolableConnectionFactory in org.apache.commons.dbcp.BasicDataS
ource
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|   1388 | createDataSource in     ''
|   1044 | getConnection in     ''
|    334 | innerRun  in java.util.concurrent.FutureTask$Sync
|    166 | run . . . in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run       in java.lang.Thread

Caused by SQLSyntaxErrorException: ORA-00923: FROM keyword not found where expec
ted

->>   91 | newSQLException in oracle.jdbc.driver.SQLStateMapping
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|    133 | newSQLException in oracle.jdbc.driver.DatabaseError
|    206 | throwSqlException in     ''
|    455 | processError in oracle.jdbc.driver.T4CTTIoer
|    413 | processError in     ''
|   1034 | receive   in oracle.jdbc.driver.T4C8Oall
|    183 | doOall8 . in oracle.jdbc.driver.T4CStatement
|    780 | executeForDescribe in     ''
|    855 | executeMaybeDescribe in     ''
|   1186 | doExecuteWithTimeout in oracle.jdbc.driver.OracleStatement
|   1377 | executeQuery in     ''
|    387 | executeQuery in oracle.jdbc.driver.OracleStatementWrapper
|    208 | executeQuery in org.apache.commons.dbcp.DelegatingStatement
|    658 | validateConnection in org.apache.commons.dbcp.PoolableConnectionFacto
ry
|   1558 | validateConnectionFactory in org.apache.commons.dbcp.BasicDataSource
|   1545 | createPoolableConnectionFactory in     ''
|   1388 | createDataSource in     ''
|   1044 | getConnection in     ''
|    334 | innerRun  in java.util.concurrent.FutureTask$Sync
|    166 | run       in java.util.concurrent.FutureTask
|   1110 | runWorker in java.util.concurrent.ThreadPoolExecutor
|    603 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
^    722 | run . . . in java.lang.Thread
| Error 2013-05-04 14:47:22,761 [localhost-startStop-1] ERROR core.StandardConte
xt  - Error listenerStart
| Error 2013-05-04 14:47:22,764 [localhost-startStop-1] ERROR core.StandardConte
xt  - Context [/gTunes] startup failed due to previous errors
| Server running. Browse to http://localhost:8080/gTunes
| Application loaded in interactive mode. Type 'stop-app' to shutdown.

(非常感谢任何见解 - 我是 Grails 的新手。谢谢)。

4

1 回答 1

2

抱歉,对grails一无所知,但这可能是问题所在:

validationQuery="SELECT 1"

这不是对 Oracle 的有效查询,ORA-00923您得到的结果很可能来自该查询。

试试这个(在你的配置文件中出现的两个地方都替换它):

validationQuery="SELECT 1 from dual"
于 2013-05-04T19:27:04.360 回答