akhikhl / gretty

Advanced gradle plugin for running web-apps on jetty and tomcat.
MIT License
659 stars 174 forks source link

Multiple SLF4J Bindings problems when using gretty #367

Open perqin opened 7 years ago

perqin commented 7 years ago

I'm switching from Cargo to gretty and use the following build.gradle:

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'org.akhikhl.gretty:gretty:+'
    }
}

apply plugin: 'java'
apply plugin: 'eclipse-wtp'
apply plugin: 'war'
apply plugin: 'org.akhikhl.gretty'

sourceCompatibility = 1.7

repositories {
    mavenCentral()
}

gretty {
    contextPath = '/'
    servletContainer = 'tomcat7'
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

And when executing task appRun, I get the following error:

:prepareInplaceWebAppFolder UP-TO-DATE
:createInplaceWebAppFolder UP-TO-DATE
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:prepareInplaceWebAppClasses UP-TO-DATE
:prepareInplaceWebApp UP-TO-DATE
:appRunSLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/perqin/workspaces/bid/bid_from_svn/bidding-gradle/libs/tika-app-1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/perqin/workspaces/bid/bid_from_svn/bidding-gradle/libs/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/perqin/workspaces/bid/bid_from_svn/bidding-gradle/libs/slf4j-log4j12-1.7.7.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
SLF4J: The requested version 1.5.6 by your slf4j binding is not compatible with [1.6, 1.7]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.

00:15:09 ERROR Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.AbstractMethodError: org.slf4j.impl.Log4jLoggerAdapter.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
        at org.apache.commons.logging.impl.SLF4JLocationAwareLog.info(SLF4JLocationAwareLog.java:159) ~[jcl-over-slf4j-1.7.7.jar:1.7.7]
        at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:285) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
        at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) ~[spring-web-4.0.5.RELEASE.jar:4.0.5.RELEASE]
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068) [tomcat-embed-core-7.0.69.jar:7.0.69]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584) [tomcat-embed-core-7.0.69.jar:7.0.69]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [tomcat-embed-core-7.0.69.jar:7.0.69]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572) [tomcat-embed-core-7.0.69.jar:7.0.69]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562) [tomcat-embed-core-7.0.69.jar:7.0.69]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
configFile /home/perqin/workspaces/bid/bid_from_svn/bidding-gradle/build/inplaceWebapp/WEB-INF/etc/conf/app-config.xml
00:15:09 ERROR Exception sending context initialized event to listener instance of class dwz.adapter.web.listener.AppContextInitListener
java.lang.AbstractMethodError: org.slf4j.impl.Log4jLoggerAdapter.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;[Ljava/lang/Object;Ljava/lang/Throwable;)V
        at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:133) ~[jcl-over-slf4j-1.7.7.jar:1.7.7]
        at org.apache.commons.configuration.ConfigurationUtils.locate(ConfigurationUtils.java:493) ~[commons-configuration-1.10.jar:1.10]
        at org.apache.commons.configuration.ConfigurationUtils.locate(ConfigurationUtils.java:429) ~[commons-configuration-1.10.jar:1.10]
        at org.apache.commons.configuration.ConfigurationFactory.getConfiguration(ConfigurationFactory.java:153) ~[commons-configuration-1.10.jar:1.10]
        at dwz.framework.config.AppConfiguration.init(AppConfiguration.java:52) ~[main/:na]
        at dwz.adapter.web.listener.AppContextInitListener.contextInitialized(AppContextInitListener.java:33) ~[main/:na]
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5068) [tomcat-embed-core-7.0.69.jar:7.0.69]
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5584) [tomcat-embed-core-7.0.69.jar:7.0.69]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) [tomcat-embed-core-7.0.69.jar:7.0.69]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1572) [tomcat-embed-core-7.0.69.jar:7.0.69]
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1562) [tomcat-embed-core-7.0.69.jar:7.0.69]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
00:15:09 ERROR One or more listeners failed to start. Full details will be found in the appropriate container log file
00:15:09 ERROR Context [] startup failed due to previous errors
00:15:09 ERROR The web application [] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.
00:15:09 INFO  Tomcat 7.0.69 started and listening on port 8080
00:15:09 INFO   runs at:
00:15:09 INFO    http://localhost:8080
Press any key to stop the server.

As it runs properly over Cargo, I am confusing why I got such error......

jonatanloya commented 7 years ago

Maybe this can helps, https://stackoverflow.com/questions/21140646/abstractmethoderror-when-try-to-initialize-spring

akhikhl commented 7 years ago

You have multiple slf4j bindings in your classpath, as error messages show. You should select only one binding, then it should work.