0

I have a task to tackle into our old Grails application which developed by our previous co-worker. The version of grails apps used is 2.2.5 and run on Java 1.7. When I run the app I get this: ( about plugins.log4j.Log4jConfig.methodMissing BeanUtils)

Resolving [runtime] dependencies... | Error log4j:ERROR Error initializing log4j: org/apache/commons/beanutils/BeanUtils | Error java.lang.NoClassDefFoundError: org/apache/commons/beanutils/BeanUtils | Error at org.codehaus.groovy.grails.plugins.log4j.Log4jConfig.methodMissing(Log4jConfig.groovy:103) | Error at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) | Error at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) | Error at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

The app does run but there is no log due to the above error message. Since there is no log so it is imposible to trace and understand the code. Thanks advance for any help.

Here are dependencies and plugin in BuildConfig.groovy

dependencies {
    runtime 'mysql:mysql-connector-java:5.1.22'
    test "org.spockframework:spock-grails-support:0.7-groovy-2.0"
    compile "org.jadira.usertype:usertype.jodatime:1.9"
    runtime 'com.paypal.sdk:rest-api-sdk:0.7.0'
}

plugins {
    runtime ":hibernate:$grailsVersion"
    runtime ":jquery:1.8.3"
    runtime ":resources:1.1.6"
    compile ':runtime-logging:0.4'
    build ":tomcat:$grailsVersion"
    compile ":spring-security-core:1.2.7.3"     
    compile ":spring-security-ui:0.2"
    compile ":famfamfam:1.0.1"
    compile ":jquery-ui:1.8.24"
    compile ":joda-time:1.4"
    compile ":quartz:1.0-RC6"
    compile ":audit-logging:0.5.4"
    compile ":console:1.2"
    compile ":mail:1.0.1"
    compile ":kickstart-with-bootstrap:0.9.6"
    runtime ":database-migration:1.3.6"
    compile ':cache:1.0.1'
    compile ':crypto:2.0'
    compile ":csv:0.3.1"
    test ":code-coverage:1.2.6"
    compile ":gmetrics:0.3.1"
    compile ":codenarc:0.23"
    compile ":export:1.6"
}

And Log4j configuration in Config.groovy

log4j = {
def gbPattern = pattern(conversionPattern: "%d{dd MMM yyyy HH:mm:ss} [%X{user_rid},%X{user_name},%X{user_action}] [%5p] %-30.30c{2} %m%n")
def infoLog = "${new File('./logs').exists() ? './logs' : '/tmp/'}/info.log"
def debugLog = "${new File('./logs').exists() ? './logs' : '/tmp/'}/debug.log"

appenders {
    console name: 'stdout', layout: gbPattern
    appender new DailyRollingFileAppender(
            name: 'debugLog',
            threshold: org.apache.log4j.Level.DEBUG,
            datePattern: "'.'yyyy-MM-dd",  // See the API for all patterns.
            fileName: debugLog,
            layout: gbPattern
    )
    appender new DailyRollingFileAppender(
            name: 'rollingLog',
            threshold: org.apache.log4j.Level.INFO,
            datePattern: "'.'yyyy-MM-dd",  // See the API for all patterns.
            fileName: infoLog,
            layout: gbPattern
    )
}

root {
    if(Environment.isDevelopmentMode()) {
        info 'stdout', 'rollingLog', 'debugLog'
    } else {
        info 'rollingLog', 'debugLog'

    }

    additivity = false
}
user332951
  • 359
  • 1
  • 3
  • 18

1 Answers1

0

Try adding bellow dependency in BuildConfig.groovy in plugins:

compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4'
Rahul Mahadik
  • 11,668
  • 6
  • 41
  • 54
  • I made changes as you suggested but now i have error of dependecies not found on url: http://repo1.maven.org/maven2/org/grails/plugins/commons-beanutils/1.9.4/commons-beanutils-1.9.4.pom. I followed this thread (https://stackoverflow.com/questions/59905086/not-able-to-build-grails-2-3-7-project-since-the-maven-central-repository-has-mo) so it could point to https but when browsing manuall to http://repo1.maven.org/maven2/org/grails there is no plugin folder. – user332951 Dec 31 '20 at 00:03