【问题标题】:Fails to start server after moving to a new spring Error starting Tomcat context移动到新的 spring 后启动服务器失败 启动 Tomcat 上下文时出错
【发布时间】:2020-09-26 12:32:27
【问题描述】:

最近,我不得不将我的项目升级到最新的 Grails、Gradle、Groovy,并且遇到了很多问题。 目前,我在启动 Tomcat 时遇到了这个特殊问题:

2020-06-07 17:23:22.919 ERROR --- [           main] o.s.b.web.embedded.tomcat.TomcatStarter  : Error starting Tomcat context. Exception: org.springframework.beans.factory.BeanCreationException. Message: Error creating bean with name 'authenticationProcessingFilterDeregistrationBean': Cannot resolve reference to bean 'authenticationProcessingFilter' while setting bean property 'filter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationProcessingFilter': Cannot resolve reference to bean 'authenticationManager' while setting bean property 'authenticationManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'authenticationManager': Cannot resolve reference to bean 'daoAuthenticationProvider' while setting constructor argument with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'daoAuthenticationProvider': Cannot resolve reference to bean 'userDetailsService' while setting bean property 'userDetailsService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userDetailsService': Unsatisfied dependency expressed through method 'setTargetDatastore' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is java.lang.NullPointerException: Cannot invoke method call() on null object
2020-06-07 17:23:22.958 ERROR --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat

我搜索了所有应该工作的 Spring 和 Grails 的可能组合,但我找不到究竟是什么不工作。

我的依赖是:

dependencies {
    // added the new way using Log4j2, yes, spring makes it easy
    compile "org.springframework.boot:spring-boot-starter-log4j2"

    // changed spring-boot-autoconfigure so that it would not
    // pull in the logback binding/implementation
    compile ('org.springframework.boot:spring-boot-autoconfigure') {
        exclude group: 'ch.qos.logback', module: 'logback-classic'
    }
    compile ('org.springframework.boot:spring-boot-starter') {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    }
    //
    compile group: 'org.springframework.security', name: 'spring-security-core', version: '5.3.2.RELEASE'
    compile group: 'org.springframework.security', name: 'spring-security-web', version: '5.3.2.RELEASE'


    // and finally, added the log4j2 binding/implementation
    compile "org.apache.logging.log4j:log4j-api:2.13.2"
    compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.2'

//    compile "org.springframework.boot:spring-boot-starter-logging"
//    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-web-boot"
    compile "org.grails:grails-logging"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-plugin-i18n"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-url-mappings"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:async"
    compile "org.grails.plugins:scaffolding"
    compile "org.grails.plugins:events"
    compile "org.grails.plugins:hibernate5"
    compile "org.hibernate:hibernate-core:5.1.10.Final"
    compile "org.grails.plugins:gsp"
    compile 'org.grails.plugins:spring-security-core:4.0.0'
    compile 'org.grails.plugins:mail:2.0.0'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'

    implementation 'com.squareup.okhttp3:okhttp:3.9.1'
    implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.9.1'

    console "org.grails:grails-console"
    profile "org.grails.profiles:web"

    runtime "org.glassfish.web:el-impl:2.1.2-b03"
    runtime "org.apache.tomcat:tomcat-jdbc"
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.14.2"
    runtime 'mysql:mysql-connector-java:5.1.29'

    testCompile "org.grails:grails-gorm-testing-support"
    testCompile "org.grails.plugins:geb"
    testCompile "org.grails:grails-web-testing-support"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}dependencies {
    // added the new way using Log4j2, yes, spring makes it easy
    compile "org.springframework.boot:spring-boot-starter-log4j2"

    // changed spring-boot-autoconfigure so that it would not
    // pull in the logback binding/implementation
    compile ('org.springframework.boot:spring-boot-autoconfigure') {
        exclude group: 'ch.qos.logback', module: 'logback-classic'
    }
    compile ('org.springframework.boot:spring-boot-starter') {
        exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    }
    //
    compile group: 'org.springframework.security', name: 'spring-security-core', version: '5.3.2.RELEASE'
    compile group: 'org.springframework.security', name: 'spring-security-web', version: '5.3.2.RELEASE'


    // and finally, added the log4j2 binding/implementation
    compile "org.apache.logging.log4j:log4j-api:2.13.2"
    compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.2'

//    compile "org.springframework.boot:spring-boot-starter-logging"
//    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-web-boot"
    compile "org.grails:grails-logging"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-plugin-i18n"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-url-mappings"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:async"
    compile "org.grails.plugins:scaffolding"
    compile "org.grails.plugins:events"
    compile "org.grails.plugins:hibernate5"
    compile "org.hibernate:hibernate-core:5.1.10.Final"
    compile "org.grails.plugins:gsp"
    compile 'org.grails.plugins:spring-security-core:4.0.0'
    compile 'org.grails.plugins:mail:2.0.0'
    compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.7'

    implementation 'com.squareup.okhttp3:okhttp:3.9.1'
    implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.9.1'

    console "org.grails:grails-console"
    profile "org.grails.profiles:web"

    runtime "org.glassfish.web:el-impl:2.1.2-b03"
    runtime "org.apache.tomcat:tomcat-jdbc"
    runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.14.2"
    runtime 'mysql:mysql-connector-java:5.1.29'

    testCompile "org.grails:grails-gorm-testing-support"
    testCompile "org.grails.plugins:geb"
    testCompile "org.grails:grails-web-testing-support"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"
}

升级前,一切正常。所有升级都是在依赖项中完成的,代码没有太大变化。仅某些密码加密。

有没有人看到或知道如何解决这个问题?

谢谢

【问题讨论】:

    标签: java spring hibernate grails grails-orm


    【解决方案1】:

    问题出在compile "org.hibernate:hibernate-core:5.1.10.Final" 版本中 - 可能有问题,在更改为compile "org.hibernate:hibernate-core:5.4.10.Final" 后一切正常。

    另外,一个领域类有 static mapping = { cache true } 这也不再起作用。

    【讨论】:

      【解决方案2】:

      在我的情况下,我有运行时 springframework,通过编译更改它并且它可以工作

      runtime 'org.springframework:spring-test:4.2.1.RELEASE'
      

      更改:

      compile 'org.springframework:spring-test:4.2.1.RELEASE'
      

      【讨论】:

        猜你喜欢
        • 2017-03-21
        • 1970-01-01
        • 2015-12-26
        • 2019-06-08
        • 1970-01-01
        • 2014-02-15
        • 2021-10-10
        • 2014-10-31
        • 2016-06-15
        相关资源
        最近更新 更多