2014-11-26 2 views
0

나는 메시지있어 Grails는 2.4.3을 사용하여 GGTS 3.6.2 내 응용 프로그램을 실행하는 경우 :Grails의 : 예외 : SQLException : 오라클 : JDBC에 대한 찾을 수 없습니다 적합 드라이버 얇은

Caused by SQLException: No suitable driver found for jdbc:oracle:thin:@server:port/OCI 
->> 689 | getConnection in java.sql.DriverManager 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 247 | getConnection in  '' 
|  18 | <init> . in awtool.Controller 
| 266 | run  in java.util.concurrent.FutureTask 
| 1142 | runWorker in java.util.concurrent.ThreadPoolExecutor 
| 617 | run  in java.util.concurrent.ThreadPoolExecutor$Worker 
^ 745 | run . . . in java.lang.Thread 
Error | 
Forked Grails VM exited with errorJava HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 

내가 많은 게시물 읽기 이 오류에 대해 설명하고 몇 가지 권장 사항을 사용했습니다. 나는

는 방법이 어떻게 할 수 있습니다

자바와 Grails의 경로가 OK입니다 ../ 도 내가 외부 JAR 추가를 사용하여 프로젝트의 Java 빌드 경로에 ojdbc6.jar 추가 lib 디렉토리 프로젝트에 ojdbc6.jar 추가 이 문제를 해결 하시겠습니까?

BuildConfig.groovy :

grails.servlet.version = "3.0" // Change depending on target container compliance (2.5 or 3.0) 
grails.project.class.dir = "target/classes" 
grails.project.test.class.dir = "target/test-classes" 
grails.project.test.reports.dir = "target/test-reports" 
grails.project.work.dir = "target/work" 
grails.project.target.level = 1.6 
grails.project.source.level = 1.6 
//grails.project.war.file = "target/${appName}-${appVersion}.war" 

grails.project.fork = [ 
    // configure settings for compilation JVM, note that if you alter the Groovy version forked compilation is required 
    compile: [maxMemory: 256, minMemory: 64, debug: false, maxPerm: 256, daemon:true], 

    // configure settings for the test-app JVM, uses the daemon by default 
    // test: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, daemon:true], 
    // configure settings for the run-app JVM 
    run: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], 
    // configure settings for the run-war JVM 
    war: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256, forkReserve:false], 
    // configure settings for the Console UI JVM 
    console: [maxMemory: 768, minMemory: 64, debug: false, maxPerm: 256] 
] 

grails.project.dependency.resolver = "maven" // or ivymaven 
grails.project.dependency.resolution = { 
    // inherit Grails' default dependencies 
    inherits("global") { 
     // specify dependency exclusions here; for example, uncomment this to disable ehcache: 
     // excludes 'ehcache' 
    } 
    log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose' 
    checksums true // Whether to verify checksums on resolve 
    legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility 

    repositories { 
     inherits true // Whether to inherit repository definitions from plugins 

     grailsPlugins() 
     grailsHome() 
     mavenLocal() 
     grailsCentral() 
     mavenCentral() 
     // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories 
     // mavenRepo "http://repository.codehaus.org" 
     // mavenRepo "http://download.java.net/maven/2/" 
     // mavenRepo "http://repository.jboss.com/maven2/" 
    mavenRepo "http://repo.spring.io/milestone/" 
    } 

    dependencies { 
     // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g. 
     runtime 'mysql:mysql-connector-java:5.1.34' 
     // runtime "com.oracle:ojdbc6:11.2.0.4" 
     // runtime 'org.postgresql:postgresql:9.3-1101-jdbc41' 
     test "org.grails:grails-datastore-test-support:1.0-grails-2.4" 
    } 

    plugins { 
     // plugins for the build system only 
     build ":tomcat:7.0.55" 

     // plugins for the compile step 
     compile ":scaffolding:2.1.2" 
     compile ':cache:1.1.7' 
     compile ":asset-pipeline:1.9.6" 
    compile ":spring-security-core:2.0-RC4" 
    compile ":spring-security-ldap:2.0-RC2" 
    compile ":force-ssl:1.0.0" 
     // plugins needed at runtime but not for compilation 
     runtime ":hibernate4:4.3.5.5" // or ":hibernate:3.6.10.17" 
     runtime ":database-migration:1.4.0" 
     runtime ":jquery:1.11.1" 

     // Uncomment these to enable additional asset-pipeline capabilities 
     //compile ":sass-asset-pipeline:1.9.0" 
     //compile ":less-asset-pipeline:1.10.0" 
     //compile ":coffee-asset-pipeline:1.8.0" 
     //compile ":handlebars-asset-pipeline:1.3.0.3" 
    } 
} 


grails.server.port.http=8088 

DataSource.groovy에

import groovy.sql.* 

dataSource { 
    pooled = true 
    dialect = "org.hibernate.dialect.MySQL5InnoDBDialect" 
    driverClassName = "com.mysql.jdbc.Driver" 
    username = "login" 
    password = "pass" 
} 
hibernate { 
    cache.use_second_level_cache = true 
    cache.use_query_cache = false 
    cache.region.factory_class = 'org.hibernate.cache.ehcache.EhCacheRegionFactory' 
} 
// environment specific settings 
environments { 
    development { 
     dataSource { 

      dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', '' 
      url = "jdbc:mysql://server:port/login" 
     } 
    } 
    test { 
     dataSource { 
      dbCreate = "update" 
      url = "jdbc:mysql://server:port/login" 
     } 
    } 
    production { 
     dataSource { 
      dbCreate = "update" 
      url = "jdbc:mysql://server:port/login" 

     } 
    } 
} 
+0

'DataSource.groovy'와'BuildConfig.groovy'를 보여주세요 – Chris

+0

@crudolf가 메인 포스트에 추가되었습니다 – lsv

답변

0

는 ".. 외부 JAR을 추가"Grails의를 사용할 때 IDE 클래스 패스에 추가하는 다른 방법은 유용하지합니다 - IDE는 Grails 의존성으로부터 클래스 패스를 구축하기 때문에 Grails가 액세스 할 수 있도록해야합니다.

당신에게

grails compile --refresh-dependencies 

을 실행하는 데 필요한 LIB 디렉토리에 항아리를 추가 (일반적으로 피해야하지만, 오라클은 귀찮게 공공의 repos에서 자신의 드라이버 항아리를 넣어 거부하기 때문에이 경우 필요)하면 클래스 패스에 추가하십시오. Grails는 잠시 동안 /lib에 항아리 자동 감지 기능을 가지고 있지 않습니다.

일단 그렇게하면 컴파일을 위해 jar 파일이 필요하다면 (이 경우는 안됨) Grails에서 IDE를 새로 고칩니다. GGTS/STS에서 왼쪽의 트리에서 프로젝트 루트 노드를 오른쪽 클릭하고 Grails Tools | 종속성 새로 고침.

1

Grails가 Oracle 라이브러리를 찾는 방법을 설명하는 Burt의 대답 외에도 DataSource.groovy을 변경하여 Oracle 데이터베이스에 연결해야합니다 (현재 MySQL 용으로 구성되어 있습니다).

dataSource { 
    pooled = true 
    driverClassName = "oracle.jdbc.driver.OracleDriver" 
    dialect = "org.hibernate.dialect.Oracle10gDialect" 
    dbCreate = "update" 
    url = 'jdbc:oracle:thin:@localhost:1521:mydb' 
    username = "root" 
    password = "password" 
    properties { 
     // See http://grails.org/doc/latest/guide/conf.html#dataSource for documentation 
     jmxEnabled = false 
     initialSize = 5 
     maxActive = 50 
     minIdle = 5 
     maxIdle = 25 
     maxWait = 10000 
     maxAge = 10 * 60000 
     timeBetweenEvictionRunsMillis = 5000 
     minEvictableIdleTimeMillis = 60000 
     validationQuery = "select 1 from dual" 
     validationQueryTimeout = 3 
     validationInterval = 15000 
     testOnBorrow = true 
     testWhileIdle = true 
     testOnReturn = false 
     jdbcInterceptors = "ConnectionState;StatementCache(max=200)" 
     defaultTransactionIsolation = Connection.TRANSACTION_READ_COMMITTED 
    } 
} 
hibernate { 
    flush.mode = 'manual' 

    cache.use_second_level_cache = true 
    cache.use_query_cache = true 
    cache.region.factory_class = "net.sf.ehcache.hibernate.EhCacheRegionFactory" 
} 

는 스키마의 이름으로 mydb, rootpassword을 교체하고 사용자 이름과 암호는 당신이 그것을 액세스하는 데 사용할 수 있습니다 : 당신은 같은 뭔가를 변경해야합니다.

+0

컨트롤러에서 mysql과 oracle의 두 연결을 사용하고 있습니다. DataSource.groovy에 설명 된 연결은 도메인 모델에 대해서만 데이터베이스에 연결하는 것입니다. – lsv

관련 문제