SLF4J library problems in groovy/lib
"Nelson, Erick" <Erick.Nelson-NXabUB82sh5Wk0Htik3J/[email protected]>
| Newsgroups | gmane.comp.lang.groovy.user |
|---|---|
| Message-ID | <BN0PR13MB476006CC774AEEF3940E94E1E7139@BN0PR13MB4760.namprd13.prod.outlook.com> |
In groovy3 there was no slf4j jar in the groovy lib dir.
But now in groovy4 there is. This file…
slf4j-api-1.7.32.jar
The problem I‘m having with this is that with this jar, my code does not seem to find logback.
I’m sure it is a classpath issue, but it’s stumping me.
I get the following to stdout when I run my test code with this jar in place….
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
And my logging is broke. The page referenced essentially says It cannot find a logger on the classpath.
If I remove said jar from the groovy lib directory all is well…code and logging execute perfectly.
My gradle dependencies…
dependencies {
implementation group: 'org.slf4j', name: 'jul-to-slf4j', version: '1.7.32'
implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.11'
implementation group: 'com.sun.mail', name: 'javax.mail', version: '1.6.2'
compileOnly group: installed_groovy_group_id, name: 'groovy', version: installed_groovy_version
compileOnly group: installed_groovy_group_id, name: 'groovy-ant', version: installed_groovy_version
compileOnly group: installed_groovy_group_id, name: 'groovy-datetime', version: installed_groovy_version
compileOnly group: installed_groovy_group_id, name: 'groovy-xml', version: installed_groovy_version
compileOnly group: installed_groovy_group_id, name: 'groovy-json', version: installed_groovy_version
compileOnly group: installed_groovy_group_id, name: 'groovy-nio', version: installed_groovy_version
compileOnly group: installed_groovy_group_id, name: 'groovy-sql', version: installed_groovy_version
compileOnly group: installed_groovy_group_id, name: 'groovy-dateutil', version: installed_groovy_version
compileOnly group: installed_groovy_group_id, name: 'groovy-cli-commons', version: installed_groovy_version
compileOnly group: 'commons-cli', name: 'commons-cli', version: '1.4'
}
The Ivy descriptor…
<dependencies>
<dependency org="org.slf4j" name="jul-to-slf4j" rev="1.7.32" force="true" conf="runtime->compile(*),runtime(*),master(*)"/>
<dependency org="ch.qos.logback" name="logback-classic" rev="1.2.11" force="true" conf="runtime->compile(*),runtime(*),master(*)"/>
<dependency org="com.sun.mail" name="javax.mail" rev="1.6.2" force="true" conf="runtime->compile(*),runtime(*),master(*)"/>
</dependencies>
Test script, if it matters…
[tauser02@cfmips01ld0s groovyscriptinglibrary]$ cat run
#!/usr/bin/env /opt/apps/tools/groovy/bin/groovy
@Grab('com.hdsupply:script:5.0')
@groovy.transform.BaseScript(script.BaseScript)
import script.*
this essently does nothing except startup the framework and do some logging.
$ ./run -v
11:47:09,780 INFO [main] run - begin
11:47:09,786 INFO [main] run - [cli options [help = false, verbose = true, debug = false, test = false]]
11:47:09,787 INFO [main] run - script file [/home/tauser02/tmp/groovyscriptinglibrary/run]
11:47:09,966 INFO [main] run - end [0.851 seconds]
I also ran this code with “-Dgroovy.grape.report.downloads=true” in JAVA_OPTS and this spits out…always, with or without the jar in groovy/lib
Resolving dependency: com.hdsupply#script;5.0 {default=[default]}
Preparing to download artifact com.hdsupply#script;5.0!script.jar
Preparing to download artifact org.slf4j#jul-to-slf4j;1.7.32!jul-to-slf4j.jar
Preparing to download artifact ch.qos.logback#logback-classic;1.2.11!logback-classic.jar
Preparing to download artifact com.sun.mail#javax.mail;1.6.2!javax.mail.jar
Preparing to download artifact org.slf4j#slf4j-api;1.7.32!slf4j-api.jar
Preparing to download artifact ch.qos.logback#logback-core;1.2.11!logback-core.jar
Preparing to download artifact javax.activation#activation;1.1!activation.jar
So my questions are..
Has anybody ever run into this before, if so, what was your solution to this classpath issue?
Why was this slf4j jar added to groovy starting with groovy4?
Do I need to a deployment step for groovy to remove this jar?
If so, are they any other downsides to this ?
Erick Nelson
Senior Developer
HD Supply, Inc.
T: 858.740.6523