Pregunta

I need to upgrade my application from 2.2.1 grails to 2.3.6 (2.3.7 has some bugs with mongodb). After upgrade I got error like:

java.lang.NoClassDefFoundError: org/springframework/jmx/support/RegistrationPolicy
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
    at java.lang.Class.getDeclaredMethods(Class.java:1855)
    at org.springframework.core.type.StandardAnnotationMetadata.hasAnnotatedMethods(StandardAnnotationMetadata.java:161)
    at org.springframework.context.annotation.ConfigurationClassUtils.isLiteConfigurationCandidate(ConfigurationClassUtils.java:106)
    at org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:87)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:233)
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:203)
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:622)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
    at org.codehaus.groovy.grails.commons.spring.DefaultRuntimeSpringConfiguration.getApplicationContext(DefaultRuntimeSpringConfiguration.java:156)
    at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:169)
    at org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator.configure(GrailsRuntimeConfigurator.java:127)
    at org.codehaus.groovy.grails.web.context.GrailsConfigUtils.configureWebApplicationContext(GrailsConfigUtils.java:122)
    at org.codehaus.groovy.grails.web.context.GrailsContextLoader.initWebApplicationContext(GrailsContextLoader.java:108)
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4973)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5467)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassNotFoundException: org.springframework.jmx.support.RegistrationPolicy
    at org.codehaus.groovy.tools.RootLoader.findClass(RootLoader.java:175)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at org.codehaus.groovy.tools.RootLoader.loadClass(RootLoader.java:147)
    at org.codehaus.groovy.grails.cli.support.GrailsRootLoader.loadClass(GrailsRootLoader.java:51)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

My BuildConfig.groovy looks like:

dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.
        compile "org.jadira.usertype:usertype.jodatime:1.9"
        compile "org.im4java:im4java:1.2.0"
        compile "org.apache.commons:commons-lang3:3.3.2"
        compile "com.googlecode.json-simple:json-simple:1.1.1"
        compile "com.rabbitmq:amqp-client:3.1.3"
        compile ("org.springframework.amqp:spring-rabbit:1.2.1.RELEASE") {
            excludes "amqp-client"
        }
        compile 'org.activiti:activiti-engine:5.12.1'
        compile 'org.activiti:activiti-spring:5.12.1'
        compile ('org.activiti:activiti-rest:5.12.1'){
            excludes 'slf4j-api'
            excludes 'slf4j-log4j'
            excludes 'slf4j-log4j12'
        }
        compile 'org.activiti:activiti-modeler:5.12.1'
        compile 'org.activiti:activiti-bpmn-converter:5.12.1'
        compile 'org.codehaus.jackson:jackson-mapper-asl:1.9.13'
        compile 'org.elasticsearch:elasticsearch-lang-groovy:2.0.0'
        compile 'com.itextpdf:itextpdf:5.0.6'
        compile 'org.springframework.integration:spring-integration-http:2.2.1.RELEASE'
        compile 'pl.fissst:fis-bps-api:1.0.0'
        compile "net.sf.ehcache:ehcache-core:2.4.6"

        //--------------------

        runtime 'org.postgresql:postgresql:9.3-1101-jdbc41'
        runtime "org.apache.pdfbox:pdfbox:1.8.4"
        runtime 'org.elasticsearch:elasticsearch:1.0.0'
        runtime 'com.vividsolutions:jts:1.13'
        runtime 'org.apache.httpcomponents:httpclient:4.3.3'
        runtime 'org.jsoup:jsoup:1.7.3'

        //---------------------

        test "xmlunit:xmlunit:1.4"
        test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
        test "org.gebish:geb-spock:$gebVersion"
        test "org.seleniumhq.selenium:selenium-chrome-driver:$seleniumVersion"

        //---------------------

        //provided 'cglib:cglib:3.1' // uncomment to enable java-melody support
    }

    plugins {
        build ":tomcat:7.0.52.1"
        build ':release:3.0.1'
        build (':rest-client-builder:2.0.1'){
            export = false
        }

        //------------------

        compile ':jmx:0.9'
        compile (":mail:1.0.4") {
            excludes 'spring-test'
        }
        compile ":joda-time:1.4"
        compile ":csv:0.3.1"
        compile ':mongodb:2.0.1'
        compile ':fixtures:1.2'
        compile ':build-test-data:2.1.2'
        compile ':teamcity:1.0.3'
        compile ':transaction-handling:0.1.3'
        compile ':plugin-config:0.2.0'
        compile ":rest:0.8"
        compile(':excel-export:0.2.1') {
            excludes "xercesImpl"
        }
        compile ':spring-security-core:2.0-RC2'
        compile ":spring-security-oauth2-provider:1.0.5.2"
        compile ':webxml:1.4.1'

        //----------------

        runtime ":hibernate:3.6.10.10"
        runtime ':executor:0.3'
        //runtime ':hibernate4:4.3.4.2'
        runtime ':database-migration:1.4.0'
        runtime ':quartz:1.0.1'
        runtime ":resources:1.2.7"
        runtime (":activiti:5.12.1") {
            excludes 'org.activiti:activiti-engine:5.12.1'
            excludes 'org.activiti:activiti-spring:5.12.1'
        }
//      runtime ':grails-melody:1.48.0-fis'

        //-----------------

        test ':code-coverage:1.2.7'
        test ":geb:$gebVersion"
        test ":cucumber:0.9.0"
    }

Anyone have any idea to solve this problem ?

¿Fue útil?

Solución

Grails 2.2.1 is based on Spring 3.1.2 while Grails 2.3.6 is based on Spring 3.2.8. The class which cannot be found is org.springframework.jmx.support.RegistrationPolicy and is part of Spring since 3.2.
This probably means that one of your dependencies or plugins depends on an older version of Spring which clashes with the one provided with Grails. The best way to find it is to run a dependency report, find this dependency and exclude it. You should take a look at the Grails documentation section about dependency resolution for more details.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top