Search code examples
tomcatgrails

Error deploy war tomcat


Im using version grails 2.5.0 and tomcat 8, in my pc i can deploy this war without problems but dont in server

I take this error:

19-Jan-2018 13:03:17.992 SEVERE [localhost-startStop-1]    org.apache.catalina.core.StandardContext.listenerStart Error configuring application listener of class [org.codehaus.groovy.grails.web.context.GrailsContextLoaderListener]
java.lang.StackOverflowError
at java.util.Hashtable.containsKey(Hashtable.java:335)
at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:57)
at org.apache.log4j.LogManager.getLogger(LogManager.java:44)
at org.slf4j.impl.GrailsSlf4jLoggerFactory.getLogger(GrailsSlf4jLoggerFactory.java:42)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
at org.apache.log4j.Category.<init>(Category.java:56)
at org.apache.log4j.Logger.<init>(Logger.java:36)
at org.apache.log4j.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:60)
at org.apache.log4j.LogManager.getLogger(LogManager.java:44)
at org.slf4j.impl.GrailsSlf4jLoggerFactory.getLogger(GrailsSlf4jLoggerFactory.java:42)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:270)
at org.apache.log4j.Category.<init>(Category.java:56)
at org.apache.log4j.Logger.<init>(Logger.java:36)

I copied same folder tomcat in my server but i take this error.

Any help?


Solution

  • It might be that there is some circular dependency of logging libraries in your project.

    To deal with this issue first of all you should check what dependencies do you have in your grails project. Run the next shell command under the project path:

    grails dependency-report > dependencies.txt
    

    Then in dependencies.txt you should check for usage of logging libraries that might be incompatible. There are few slf4j libraries that cause infinite loop if used simultaneously.

    From slf4j documentation:

    log4j-over-slf4j.jar and slf4j-log4j12.jar cannot be present simultaneously

    jul-to-slf4j.jar and slf4j-jdk14.jar cannot be present simultaneously

    For more details see: https://www.slf4j.org/legacy.html

    For example, for me the fix was to exclude log4j-over-slf4j and bcprov-jdk15 dependenies from spring-security-rest plugin

    plugins {
        ...
        compile ("org.grails.plugins:spring-security-rest:1.5.3") {
            excludes "log4j-over-slf4j", "bcprov-jdk15"
        }
    }