Hi,
I was using the tomcat-plugin in Gradle 2.1 and add startup it used to complain about multiple SLF4J bindings but I could test my application normally. Follows the console message:
:tomcatRun
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/eugenio/.gvm/gradle/2.1/lib/logback-classic-1.0.13.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/eugenio/.gradle/caches/modules-2/files-2.1/org.jboss.weld.servlet/weld-servlet/2.0.3.Final/82e9133e3c56e7fb2ac6489c65337b1f7d584396/weld-servlet-2.0.3.Final.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.JDK14LoggerFactory]
Context Initializing... Configuring log4j...
Current thread: Thread[localhost-startStop-1,5,main]
...
When I upgraded to Gradle 2.4, now I can see that Gradle itself has incorporated a StaticLoggerBinder and the SLF4J warning is different and the application now refuses to start:
:tomcatRun
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/Users/eugenio/.gvm/gradle/2.4/lib/gradle-core-2.4.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/Users/eugenio/.gradle/caches/modules-2/files-2.1/org.jboss.weld.servlet/weld-servlet/2.0.3.Final/82e9133e3c56e7fb2ac6489c65337b1f7d584396/weld-servlet-2.0.3.Final.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
Failed to instantiate SLF4J LoggerFactory
Reported exception:
java.lang.NoClassDefFoundError: org/slf4j/spi/LoggerFactoryBinder
at java.lang.ClassLoader.defineClass1(Native Method)
...
The main parts of the build file are as follows:
defaultTasks 'tomcatRun'
apply plugin:'java'
apply plugin:'war'
apply plugin:'tomcat'
version = '0.0.1-SNAPSHOT'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "org.gradle.api.plugins:gradle-tomcat-plugin:1.0"
}
}
repositories {
flatDir {
dirs 'lib'
}
mavenCentral()
mavenLocal()
jcenter()
}
configurations {
compile
tomcat
generate
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:1.8.6'
compile 'commons-beanutils:commons-beanutils:1.8.3'
compile 'commons-collections:commons-collections:3.2.1'
compile 'commons-digester:commons-digester:1.8.1'
compile 'commons-logging:commons-logging:1.1.1'
providedCompile 'javax.servlet:servlet-api:2.5'
providedRuntime 'javax.el:el-api:2.2'
providedRuntime 'org.jboss.spec.javax.el:jboss-el-api_3.0_spec:1.0.0.Alpha1'
providedRuntime 'org.slf4j:slf4j-api:+'
providedRuntime 'org.slf4j:slf4j-ext:+'
providedRuntime 'org.slf4j:slf4j-log4j12:+'
compile 'org.directwebremoting:dwr:2.0.2'
compile 'joda-time:joda-time:2.1'
compile 'hsqldb:hsqldb:1.8.0.10'
runtime 'javax.servlet:jstl:1.2'
runtime 'org.jboss.weld.servlet:weld-servlet:2.0.3.Final'
runtime 'org.jboss.weld.servlet:weld-servlet:2.0.3.Final'
runtime 'org.jboss.weld.se:weld-se-core:2.0.3.Final'
def tomcatVersion = '7.0.37'
tomcat "org.apache.tomcat.embed:tomcat-embed-core:${tomcatVersion}",
"org.apache.tomcat.embed:tomcat-embed-logging-juli:${tomcatVersion}"
tomcat("org.apache.tomcat.embed:tomcat-embed-jasper:${tomcatVersion}") {
exclude group: 'org.eclipse.jdt.core.compiler', module: 'ecj'
}
}
jar.enabled = true
war {
classpath = jar.outputs.files + configurations.runtime - configurations.providedRuntime
}
tomcatRun {
URIEncoding = 'UTF-8'
}
I’ve switched back to 2.1 (using GVM), the warnings are shown, but no exception is logged.
Any suggestions?
Thanks.