2013-03-05 2 views
0

У меня возникает ошибка при попытке инициализировать приложение Grails. Я хочу подключиться к базе данных Sybase, поэтому у меня был файл конфигурации с соответствующими данными. Вот ошибка.Ошибка конфигурации источника данных Grails При запуске приложения

 | Loading Grails 2.2.1 
| Configuring classpath 
| Configuring classpath. 
| Environment set to development 
| Environment set to development. 
| Environment set to development.. 
| Environment set to development... 
| Environment set to development.... 
| Environment set to development..... 
| Packaging Grails application 
| Packaging Grails application. 
| Packaging Grails application.. 
| Packaging Grails application... 
| Packaging Grails application.... 
| Compiling 1 source files 
| Compiling 1 source files. 
| Compiling 1 source files.. 
| Compiling 1 source files... 
| Compiling 1 source files.... 
| Compiling 1 source files.... 
| Compiling 1 source files.... 
| Compiling 1 source files..... 
| Compiling 1 source files..... 
| Compiling 1 source files..... 
| Running Grails application 
| Error 2013-03-05 13:06:40,074 [localhost-startStop-1] ERROR context.GrailsContextLoader - Error initializing the application: Error creating bean with name 'transactionManagerPostProcessor': Ini 
tialization of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to bean 'sessio 
nFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory': Cannot resolve r 
eference to bean 'lobHandlerDetector' while setting bean property 'lobHandler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandle 
rDetector': Invocation of init method failed; nested exception is org.springframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.c 
ommons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.sybase.jdbc3.jdbc.SybDriver' 
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.BeanCreati 
onException: 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.MetaDataAccessExcepti 
on: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.sybase.jdbc3.jdbc.SybDriver' 
    Line | Method 
->> 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 'lobHa 
ndler'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'lobHandlerDetector': Invocation of init method failed; nested exception is org.sp 
ringframework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.sybas 
e.jdbc3.jdbc.SybDriver' 
->> 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.M 
etaDataAccessException: Error while extracting DatabaseMetaData; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.sybase.jdbc3.jdbc.SybDriver' 
->> 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 load JDBC driver class 'com.sybase.jdbc3.jdbc.SybDriver' 
->> 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 load JDBC driver class 'com.sybase.jdbc3.jdbc.SybD 
river' 
->> 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 load JDBC driver class 'com.sybase.jdbc3.jdbc.SybDriver' 
->> 1429 | 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 ClassNotFoundException: com.sybase.jdbc3.jdbc.SybDriver 
->> 59 | findClass in org.grails.plugins.tomcat.ParentDelegatingClassLoader 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
| 306 | loadClass in java.lang.ClassLoader 
| 247 | loadClass in  '' 
| 1420 | 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 

Какое изменение следует внести в Datasource.groovy (если это причина)? Вот.

dataSource { 
    pooled = true 
    driverClassName ="com.sybase.jdbc3.jdbc.SybDriver" 
    username = "starry" 
    password = "allcodes" 

    dialect = org.hibernate.dialect.SybaseDialect 
} 
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 { 
      dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', '' 
      url = "jdbc:sybase:Tds:he2unx182:3025/cei001db" 
     } 
    } 
    test { 
     dataSource { 
      dbCreate = "update" 
      url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000" 
     } 
    } 
    production { 
     dataSource { 
      dbCreate = "update" 
      url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000" 
      pooled = true 
      properties { 
       maxActive = -1 
       minEvictableIdleTimeMillis=1800000 
       timeBetweenEvictionRunsMillis=1800000 
       numTestsPerEvictionRun=3 
       testOnBorrow=true 
       testWhileIdle=true 
       testOnReturn=true 
       validationQuery="SELECT 1" 
      } 
     } 
    } 
} 
+0

Возможно, это глупый вопрос, но у вас есть драйвер Sybase jdbc, фактически установленный в каталоге 'lib'? – Kelly

ответ

2

Прокрутить вниз - говорится ClassNotFoundException: com.sybase.jdbc3.jdbc.SybDriver. Если вы поместили jar в каталог lib (не рекомендуется), запустите grails compile --refresh-dependencies, чтобы добавить его в путь к классам.

Лучше использовать зависимость в BuildConfig.groovy для этого, например.

dependencies { 
    compile 'net.sourceforge.jtds:jtds:1.3.0' 
} 
+0

Берт и Келли Хорошо. Я помещал банки в каталог lib приложения и скомпилировал. Он по-прежнему дает ту же ошибку. Теперь я попробую объявить его как зависимость, как упоминал Берт. – user2136630

+0

Все еще давая classnotfound mgr1 @ hq4unxd104z03:/tmp/rohit/logs> cat log10.log | grep "ClassNot" Вызвано ClassNotFoundException: com.sybase.jdbc3.jdbc.SybDriver lrdtmgr1 @ hq4unxd104z03:/tmp/rohit/logs> – user2136630

+0

Привет, ребята, я установил CLASSPATH из Unix в библиотеки (jconn3.jar и т. д.), и теперь он подключается к БД. Он по-прежнему дает другую ошибку, потому что у меня нет разрешения на изменение таблиц. Но да. Моя задача выполнена. Огромное спасибо за помощь!! – user2136630