Grails与MSSQL服务器 [英] Grails with MSSQL Server

查看:120
本文介绍了Grails与MSSQL服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建我的第一个Grails应用程序,但将我的应用程序连接到MSSQL服务器时存在一些问题。



我的操作是(通过Windows cmd):
$ b $ ol

  • 命令 grails create-app hello

  • 命令 cd hello
  • 然后我配置了dataSource文件:

      dataSource {

    pooled = true
    jmxExport = true
    driverClassName =com.microsoft.sqlserver.jdbc.SQLServerDriver
    username =login
    密码=密码}

    环境{

    开发{
    dataSource {
    dbCreate =update
    url =jdbc :jtds:sqlserver:\\< server-ip> ;; databaseName = Grails

    }
    test {
    dataSource {
    dbCreate =update
    url =jdbc:jtds:sqlserver:\\< server-ip> ;; databaseName = Grails

    }
    生产{
    dataSource {
    dbCreate =update
    url =jdbc:jtds:sqlserver:\\< server-ip> ;; databaseNa me = Grails

    }
    }
    }

    基本的Grails是在SQL Server中创建的。

    然后我配置了域类Hi.groovy

      class Hi {
    String word
    int num
    static constraints = {
    }
    }
  • 最后,我通过命令运行我的应用程序 grails run-app

  • 我认为在我的Grails基础中应该创建具有两个字段的新表Hi,但是我得到错误与这样的stacktrace:

      |配置classpath 
    ёхэ01,2014 2:54:33 PM java.util.prefs.WindowsPreferences< init>
    警告:无法打开/创建首选项根节点Software \JavaSoft\Prefs at root 0
    |运行Grails应用程序
    错误|
    2014-09-01 14:54:50,750 [localhost-startStop-1]错误pool.ConnectionPool - Una
    ble创建池的初始连接。
    消息:com.microsoft.sqlserver.jdbc.SQLServerDriver
    行|方法
    - >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 166 |在java.util.concurrent.FutureTask
    |运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |中运行跑 。 。 。在java.lang.Thread中
    由ClassNotFoundException引起:com.microsoft.sqlserver.jdbc.SQLServerDriver
    - >> 366 |在java.net.URLClassLoader中运行$ 1
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 355 |在''
    |运行354 | java.net.URLClassLoader
    中的findClass 423 | java.lang.ClassLoader中的loadClass
    | 266 | forName。在java.lang.Class
    |中334 |在java.util.concurrent.FutureTask $ Sync
    |中的innerRun 166 |跑 。 。 。在java.util.concurrent.FutureTask
    |中1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |跑 。 。 。在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |在java.lang.Thread中运行
    Error |
    2014-09-01 14:54:50,798 [localhost-startStop-1]错误pool.ConnectionPool - Una
    ble创建池的初始连接。
    消息:com.microsoft.sqlserver.jdbc.SQLServerDriver
    行|方法
    - >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 166 |在java.util.concurrent.FutureTask
    |运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |中运行跑 。 。 。在java.lang.Thread中
    由ClassNotFoundException引起:com.microsoft.sqlserver.jdbc.SQLServerDriver
    - >> 366 |在java.net.URLClassLoader中运行$ 1
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 355 |在''
    |运行354 | java.net.URLClassLoader
    中的findClass 423 | java.lang.ClassLoader中的loadClass
    | 266 | forName。在java.lang.Class
    |中334 |在java.util.concurrent.FutureTask $ Sync
    |中的innerRun 166 |跑 。 。 。在java.util.concurrent.FutureTask
    |中1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |跑 。 。 。在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |在java.lang.Thread中运行
    Error |
    2014-09-01 14:54:50,841 [localhost-startStop-1]错误pool.ConnectionPool - Una
    ble创建池的初始连接。
    消息:com.microsoft.sqlserver.jdbc.SQLServerDriver
    行|方法
    - >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 166 |在java.util.concurrent.FutureTask
    |运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |中运行跑 。 。 。在java.lang.Thread中
    由ClassNotFoundException引起:com.microsoft.sqlserver.jdbc.SQLServerDriver
    - >> 366 |在java.net.URLClassLoader中运行$ 1
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 355 |在''
    |运行354 | java.net.URLClassLoader
    中的findClass 423 | java.lang.ClassLoader中的loadClass
    | 266 | forName。在java.lang.Class
    |中334 |在java.util.concurrent.FutureTask $ Sync
    |中的innerRun 166 |跑 。 。 。在java.util.concurrent.FutureTask
    |中1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |跑 。 。 。在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |在java.lang.Thread中运行
    Error |
    2014-09-01 14:54:50,860 [localhost-startStop-1] ERROR context.GrailsContextLoade
    rListener - 初始化应用程序时出错:创建名为'
    transactionManagerPostProcessor'的bean时出错:初始化豆失败了;嵌套的exceptio
    n是org.springframework.beans.factory.BeanCreationException:创建名为'transactionManager'的be
    n时出错:无法在设置bean属性'sessionFactory'时解析对bean'sessionFacto
    ry'的引用;嵌套异常是org.spring
    framework.beans.factory.BeanCreationException:创建名为'se
    ssionFactory'的bean时出错:无法解析对bean'hibernateProperties'的引用,同时设置
    ing bean属性' hibernateProperties';嵌套异常是org.springframework
    .beans.factory.BeanCreationException:创建名为'hibernatePr
    operties'的bean时出错:无法在设置bean时解析对bean'dialectDetector'的引用
    property'properties'用键[hibernate.dialect];嵌套的异常是org.spr
    ingframework.beans.factory.BeanCreationException:创建名为
    的方法时出错'b'dialectDetector':调用init方法失败;嵌套的异常是org.spr
    ingframework.jdbc.support.MetaDataAccessException:提取Databa时出错
    seMetaData;嵌套的异常是java.sql.SQLException:com.microsoft.sqlserver.j
    dbc.SQLServerDriver
    消息:创建名为'transactionManagerPostProcessor'的bean时出错:Initia
    bean失败;嵌套异常是org.springframework.beans.factory.B
    eanCreationException:创建名为'transactionManager'的bean时出错:无法
    在设置bean属性'session
    时解析对bean'sessionFactory'的引用工厂;嵌套异常是org.springframework.beans.factory.BeanCreationExce
    ption:创建名为'sessionFactory'的bean时出错:无法在设置bean属性'hibernateProperties'时将引用
    解析为bean'hibernateProperties';
    嵌套的异常是org.springframework.beans.factory.BeanCreationException:Er
    ror创建名为'hibernateProperties'的bean:无法解析对b
    '''dialectDetector'的引用,同时设置bean属性'属性'与关键[hiberna
    te.dialect];嵌套异常是org.springframework.beans.factory.BeanCreationE
    xception:创建名为'dialectDetector'的bean时出错:调用init me
    thod失败;嵌套异常是org.springframework.jdbc.support.MetaDataAccess
    异常:提取DatabaseMetaData时出错;嵌套异常是java.sql
    .SQLException:com.microsoft.sqlserver.jdbc.SQLServerDriver
    行|方法
    - >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 166 |在java.util.concurrent.FutureTask
    |运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |中运行跑 。 。 。在java.lang.Thread中
    导致BeanCreationException:创建名为'transactionManag
    er'的bean时出错:无法在设置bean时解析对bean'sessionFactory'的引用
    ''sessionFactory';嵌套异常是org.springframework.beans.factory.BeanC
    reationException:创建名为'sessionFactory'的bean时出错:无法在设置bean属性'hibernateP
    roperties时解析
    引用bean'hibernateProperties' ;嵌套异常是org.springframework.beans.factory.BeanCreationEx
    ception:创建名为'hibernateProperties'的Bean时出错:无法使用k $设置bean属性'properties'时无法解析ref
    'bean'dialectDetector' b $ b ey [hibernate.dialect];嵌套的异常是org.springframework.beans.factory.Be
    anCreationException:创建名为'dialectDetector'的bean时出错:init方法的调用
    失败;嵌套异常是org.springframework.jdbc.support.Met
    aDataAccessException:提取DatabaseMetaData时出错;嵌套异常
    是java.sql.SQLException:com.microsoft.sqlserver.jdbc.SQLServerDriver
    - >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 166 |在java.util.concurrent.FutureTask
    |运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |中运行跑 。 。 。在java.lang.Thread中
    由BeanCreationException引发:创建名为'sessionFactory'的bean时出错:
    在设置bean prope
    rty'hibernateProperties'时无法解析对bean'hibernateProperties'的引用。嵌套异常是org.springframework.beans.factory
    .BeanCreationException:创建名为'hibernateProperties'的Bean时出错:
    可以在设置bean属性'pro
    perties时解析对bean'dialectDetector'的引用'用键[hibernate.dialect];嵌套异常是org.springframework.b
    eans.factory.BeanCreationException:使用名称'dialectDetect
    或'创建bean时出错:init方法的调用失败;嵌套异常是org.springframework.j
    dbc.support.MetaDataAccessException:提取DatabaseMetaData时出错; ne
    sted异常是java.sql.SQLException:com.microsoft.sqlserver.jdbc.SQLServerD
    river
    - >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 166 |在java.util.concurrent.FutureTask
    |运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |中运行跑 。 。 。在java.lang.Thread中
    引起BeanCreationException:创建名为'hibernatePropert
    ies'的bean时出错:设置bean prop
    erty'properties'时使用键无法解析对bean'dialectDetector'的引用[hibernate.dialect];嵌套的异常是org.springfr
    amework.beans.factory.BeanCreationException:创建名为'dial
    ectDetector'的bean时出错:init方法的调用失败;嵌套异常是org.springfr
    amework.jdbc.support.MetaDataAccessException:提取DatabaseMet
    aData时出错;嵌套异常是java.sql.SQLException:com.microsoft.sqlserver.jdbc.S
    QLServerDriver
    - >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 166 |在java.util.concurrent.FutureTask
    |运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |中运行跑 。 。 。在java.lang.Thread中
    由BeanCreationException引发:创建名为'dialectDetector'的bean时出错
    :调用init方法失败;嵌套异常是org.springframework.jdbc
    .support.MetaDataAccessException:提取DatabaseMetaData时出错; neste
    d异常是java.sql.SQLException:com.microsoft.sqlserver.jdbc.SQLServerDriv
    er
    - >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 166 |在java.util.concurrent.FutureTask
    |运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |中运行跑 。 。 。在java.lang.Thread中
    导致MetaDataAccessException:提取DatabaseMetaData时出错;嵌套
    编辑异常是java.sql.SQLException:com.microsoft.sqlserver.jdbc.SQLServerDri
    ver
    - >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 166 |在java.util.concurrent.FutureTask
    |运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |中运行跑 。 。 。 in java.lang.Thread
    由SQLException引起:com.microsoft.sqlserver.jdbc.SQLServerDriver
    - >> 334 | innerRun in java.util.concurrent.FutureTask $ Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 166 |在java.util.concurrent.FutureTask
    |运行1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |中运行跑 。 。 。在java.lang.Thread中
    由ClassNotFoundException引起:com.microsoft.sqlserver.jdbc.SQLServerDriver
    - >> 366 |在java.net.URLClassLoader中运行$ 1
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    | 355 |在''
    |运行354 | java.net.URLClassLoader
    中的findClass 423 | java.lang.ClassLoader中的loadClass
    | 266 | forName。在java.lang.Class
    |中334 |在java.util.concurrent.FutureTask $ Sync
    |中的innerRun 166 |跑 。 。 。在java.util.concurrent.FutureTask
    |中1145 | java.util.concurrent.ThreadPoolExecutor中的runWorker
    | 615 |跑 。 。 。在java.util.concurrent.ThreadPoolExecutor $ Worker
    ^ 722 |在java.lang.Thread
    |运行错误分叉Grails虚拟机退出,出现错误

    我做错了什么?

    解决方案

    原因是无法加载JDBC驱动程序,如跟踪中所报告的那样:


    ClassNotFoundException:com.microsoft.sqlserver.jdbc.SQLServerDriver

    我在我的DataSource.groovy中使用以下内容:

      driverClassName =net.sourceforge.jtds.jdbc.Driver
    dialect =org.hibernate.dialect。 SQLServerDialect

    然后在BuildConfig.groovy中加入如下内容:

     依赖关系{
    运行时'net.sourceforge.jtds:jtds:1.3.0'
    }


    I tried to create my first grails app, but there is some problems with connection my app to MSSQL server.

    My actions were(by windows cmd):

    1. Command grails create-app hello
    2. Command cd hello
    3. After that I configured dataSource file:

      dataSource {
      
      pooled = true
      jmxExport = true
      driverClassName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"
      username = "login"
      password = "password" }
      
      environments {
      
      development {
          dataSource {
              dbCreate = "update"
              url = "jdbc:jtds:sqlserver:\\<server-ip>;databaseName=Grails"
          }
      }
      test {
          dataSource {
              dbCreate = "update"
              url = "jdbc:jtds:sqlserver:\\<server-ip>;databaseName=Grails"
          }
      }
      production {
          dataSource {
              dbCreate = "update"
              url = "jdbc:jtds:sqlserver:\\<server-ip>;databaseName=Grails"
      
          }
      } 
      }
      

      Base "Grails" was alredy created in SQL Server.

    4. Command grails create-domain-class Hi

      Then I configured domain class Hi.groovy

      class Hi { 
         String word  
         int num
         static constraints = {
         } 
      }
      

    5. And finally I ran my app by command grails run-app

    I think that in my Grails base should create new table Hi with two fields, but i get error with such stacktrace:

        | Configuring classpath
    ёхэ 01, 2014 2:54:33 PM java.util.prefs.WindowsPreferences <init>
    WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0
    | Running Grails application
    Error |
    2014-09-01 14:54:50,750 [localhost-startStop-1] ERROR pool.ConnectionPool  - Una
    ble to create initial connections of pool.
    Message: com.microsoft.sqlserver.jdbc.SQLServerDriver
        Line | Method
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    166 | run       in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    ->>  366 | run       in java.net.URLClassLoader$1
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    355 | run       in     ''
    |    354 | findClass in java.net.URLClassLoader
    |    423 | loadClass in java.lang.ClassLoader
    |    266 | forName . in java.lang.Class
    |    334 | innerRun  in java.util.concurrent.FutureTask$Sync
    |    166 | run . . . in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run       in java.lang.Thread
    Error |
    2014-09-01 14:54:50,798 [localhost-startStop-1] ERROR pool.ConnectionPool  - Una
    ble to create initial connections of pool.
    Message: com.microsoft.sqlserver.jdbc.SQLServerDriver
        Line | Method
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    166 | run       in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    ->>  366 | run       in java.net.URLClassLoader$1
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    355 | run       in     ''
    |    354 | findClass in java.net.URLClassLoader
    |    423 | loadClass in java.lang.ClassLoader
    |    266 | forName . in java.lang.Class
    |    334 | innerRun  in java.util.concurrent.FutureTask$Sync
    |    166 | run . . . in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run       in java.lang.Thread
    Error |
    2014-09-01 14:54:50,841 [localhost-startStop-1] ERROR pool.ConnectionPool  - Una
    ble to create initial connections of pool.
    Message: com.microsoft.sqlserver.jdbc.SQLServerDriver
        Line | Method
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    166 | run       in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    ->>  366 | run       in java.net.URLClassLoader$1
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    355 | run       in     ''
    |    354 | findClass in java.net.URLClassLoader
    |    423 | loadClass in java.lang.ClassLoader
    |    266 | forName . in java.lang.Class
    |    334 | innerRun  in java.util.concurrent.FutureTask$Sync
    |    166 | run . . . in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run       in java.lang.Thread
    Error |
    2014-09-01 14:54:50,860 [localhost-startStop-1] ERROR context.GrailsContextLoade
    rListener  - Error initializing the application: Error creating bean with name '
    transactionManagerPostProcessor': Initialization of bean failed; nested exceptio
    n is org.springframework.beans.factory.BeanCreationException: Error creating bea
    n with name 'transactionManager': Cannot resolve reference to bean 'sessionFacto
    ry' while setting bean property 'sessionFactory'; nested exception is org.spring
    framework.beans.factory.BeanCreationException: Error creating bean with name 'se
    ssionFactory': Cannot resolve reference to bean 'hibernateProperties' while sett
    ing bean property 'hibernateProperties'; nested exception is org.springframework
    .beans.factory.BeanCreationException: Error creating bean with name 'hibernatePr
    operties': Cannot resolve reference to bean 'dialectDetector' while setting bean
     property 'properties' with key [hibernate.dialect]; nested exception is org.spr
    ingframework.beans.factory.BeanCreationException: Error creating bean with name
    'dialectDetector': Invocation of init method failed; nested exception is org.spr
    ingframework.jdbc.support.MetaDataAccessException: Error while extracting Databa
    seMetaData; nested exception is java.sql.SQLException: com.microsoft.sqlserver.j
    dbc.SQLServerDriver
    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 'hibernateProperties' while setting bean property 'hibernateProperties';
     nested exception is org.springframework.beans.factory.BeanCreationException: Er
    ror creating bean with name 'hibernateProperties': Cannot resolve reference to b
    ean 'dialectDetector' while setting bean property 'properties' with key [hiberna
    te.dialect]; nested exception is org.springframework.beans.factory.BeanCreationE
    xception: Error creating bean with name 'dialectDetector': Invocation of init me
    thod failed; nested exception is org.springframework.jdbc.support.MetaDataAccess
    Exception: Error while extracting DatabaseMetaData; nested exception is java.sql
    .SQLException: com.microsoft.sqlserver.jdbc.SQLServerDriver
        Line | Method
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    166 | run       in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | 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 'hibernateProperties' while setting bean property 'hibernateP
    roperties'; nested exception is org.springframework.beans.factory.BeanCreationEx
    ception: Error creating bean with name 'hibernateProperties': Cannot resolve ref
    erence to bean 'dialectDetector' while setting bean property 'properties' with k
    ey [hibernate.dialect]; nested exception is org.springframework.beans.factory.Be
    anCreationException: Error creating bean with name 'dialectDetector': Invocation
     of init method failed; nested exception is org.springframework.jdbc.support.Met
    aDataAccessException: Error while extracting DatabaseMetaData; nested exception
    is java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    166 | run       in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | 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 'hibernateProperties' while setting bean prope
    rty 'hibernateProperties'; nested exception is org.springframework.beans.factory
    .BeanCreationException: Error creating bean with name 'hibernateProperties': Can
    not resolve reference to bean 'dialectDetector' while setting bean property 'pro
    perties' with key [hibernate.dialect]; nested exception is org.springframework.b
    eans.factory.BeanCreationException: Error creating bean with name 'dialectDetect
    or': Invocation of init method failed; nested exception is org.springframework.j
    dbc.support.MetaDataAccessException: Error while extracting DatabaseMetaData; ne
    sted exception is java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerD
    river
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    166 | run       in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by BeanCreationException: Error creating bean with name 'hibernatePropert
    ies': Cannot resolve reference to bean 'dialectDetector' while setting bean prop
    erty 'properties' with key [hibernate.dialect]; nested exception is org.springfr
    amework.beans.factory.BeanCreationException: Error creating bean with name 'dial
    ectDetector': Invocation of init method failed; nested exception is org.springfr
    amework.jdbc.support.MetaDataAccessException: Error while extracting DatabaseMet
    aData; nested exception is java.sql.SQLException: com.microsoft.sqlserver.jdbc.S
    QLServerDriver
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    166 | run       in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by BeanCreationException: Error creating bean with name 'dialectDetector'
    : Invocation of init method failed; nested exception is org.springframework.jdbc
    .support.MetaDataAccessException: Error while extracting DatabaseMetaData; neste
    d exception is java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerDriv
    er
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    166 | run       in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by MetaDataAccessException: Error while extracting DatabaseMetaData; nest
    ed exception is java.sql.SQLException: com.microsoft.sqlserver.jdbc.SQLServerDri
    ver
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    166 | run       in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by SQLException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    ->>  334 | innerRun  in java.util.concurrent.FutureTask$Sync
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    166 | run       in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run       in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run . . . in java.lang.Thread
    Caused by ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver
    ->>  366 | run       in java.net.URLClassLoader$1
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    |    355 | run       in     ''
    |    354 | findClass in java.net.URLClassLoader
    |    423 | loadClass in java.lang.ClassLoader
    |    266 | forName . in java.lang.Class
    |    334 | innerRun  in java.util.concurrent.FutureTask$Sync
    |    166 | run . . . in java.util.concurrent.FutureTask
    |   1145 | runWorker in java.util.concurrent.ThreadPoolExecutor
    |    615 | run . . . in java.util.concurrent.ThreadPoolExecutor$Worker
    ^    722 | run       in java.lang.Thread
    | Error Forked Grails VM exited with error
    

    What am I doing wrong?

    解决方案

    The cause is that the JDBC driver cannot be loaded, as reported in the traces:

    ClassNotFoundException: com.microsoft.sqlserver.jdbc.SQLServerDriver

    I use the following in my DataSource.groovy:

    driverClassName = "net.sourceforge.jtds.jdbc.Driver"
    dialect = "org.hibernate.dialect.SQLServerDialect"
    

    And in BuildConfig.groovy put something like:

    dependencies {
        runtime 'net.sourceforge.jtds:jtds:1.3.0'
    }
    

    这篇关于Grails与MSSQL服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆