<div dir="ltr">jcl-over-slf4j is not a binding, it's an adapter. It implements the Apache Jakarta Commons Logging API, but instead of using the JCL to route log messages, it uses the installed SLF4j binding. But, it is true that the different SLF4j jars be of compatible versions. I think the actual problem that you are running into is that you have specifically included a runtime binding jar, but you didn't mention whether you also explicitly include the slf4j-api jar as a compile time dependency. If you didn't it will include the highest one explicitly included, which is the one specified by the ant.jar. <div><br></div><div>If I were you I would absolutely include the slf4j-api compile dependency, and probably the jcl-over-slf4j runtime dependency using the same version as your binding.</div><div> (*Chris*)</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, May 7, 2015 at 12:04 AM, Strachan, Paul <span dir="ltr"><<a href="mailto:Paul.Strachan@det.nsw.edu.au" target="_blank">Paul.Strachan@det.nsw.edu.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div lang="EN-AU" link="blue" vlink="purple">
<div>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’m creating a Groovy/JavaFX app which invokes an ant build script from a 3<sup>rd</sup> party software product installed on the same host. My app (Griffon) has a runtime dependency of slf4j-log4j12-1.7.10. I’ve also added ant-1.9.4 as
a compile dependency.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The ant build file imports other build scripts (from the 3rd party “scripts” folder) which import others and eventually the necessary taskdef and classpath refs are created – this classpath uses an older slf4j implantation containing: jcl-over-slf4j-1.5.2.jar,
slf4j-log4j12-1.5.2.jar, slf4j-api-1.5.2.jar<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">At runtime when I execute the target I’m seeing the following error and the ant task did not complete:<u></u><u></u></p>
<pre style="background:white"><b><span style="font-size:9.0pt;color:#000043">def </span></b><span style="font-size:9.0pt;color:black">antProject = </span><b><span style="font-size:9.0pt;color:#000043">new </span></b><span style="font-size:9.0pt;color:black">Project()<br>antProject.init()<br>ProjectHelper.<i>configureProject</i>(antProject, buildFile)<u></u><u></u></span></pre>
<pre style="background:white"><span style="font-size:9.0pt;color:black">antProject.executeTarget(</span><b><span style="font-size:9.0pt;color:green">'</span></b><span style="font-size:9.0pt;color:black">export</span><b><span style="font-size:9.0pt;color:green">'</span></b><span style="font-size:9.0pt;color:black">)<br><br><u></u><u></u></span></pre>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Caused by: java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V<u></u><u></u></p>
<p class="MsoNormal"> at org.apache.commons.logging.impl.SLF4JLocationAwareLog.warn(SLF4JLocationAwareLog.java:173)<u></u><u></u></p>
<p class="MsoNormal"> at org.apache.axis2.util.Loader.getResourceAsStream(Loader.java:140)<u></u><u></u></p>
<p class="MsoNormal"> at org.apache.axis2.deployment.FileSystemConfigurator.getAxisConfiguration(FileSystemConfigurator.java:113)<u></u><u></u></p>
<p class="MsoNormal"> at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContext(ConfigurationContextFactory.java:68)<u></u><u></u></p>
<p class="MsoNormal"> at org.apache.axis2.context.ConfigurationContextFactory.createConfigurationContextFromFileSystem(ConfigurationContextFactory.java:184)<u></u><u></u></p>
<p class="MsoNormal"> at org.apache.axis2.client.ServiceClient.configureServiceClient(ServiceClient.java:150)<u></u><u></u></p>
<p class="MsoNormal"> at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:143)<u></u><u></u></p>
<p class="MsoNormal"> at org.apache.axis2.client.ServiceClient.<init>(ServiceClient.java:244)<u></u><u></u></p>
<p class="MsoNormal"> at org.apache.axis2.rpc.client.RPCServiceClient.<init>(RPCServiceClient.java:48)<u></u><u></u></p>
<p class="MsoNormal"> at com.tibco.amf.admin.api.servicefactory.remote.axis2.Axis2ProxyServiceFactory$Axis2ServiceInvocation.<init>(Axis2ProxyServiceFactory.java:185)<u></u><u></u></p>
<p class="MsoNormal"> at com.tibco.amf.admin.api.servicefactory.remote.axis2.Axis2ProxyServiceFactory.createService(Axis2ProxyServiceFactory.java:168)<u></u><u></u></p>
<p class="MsoNormal"> at com.tibco.amf.admin.api.servicefactory.remote.RemoteServicesRegistry.getRemoteServiceInstance(RemoteServicesRegistry.java:112)<u></u><u></u></p>
<p class="MsoNormal"> at com.tibco.amf.admin.cmdline.ServiceFactory.createService(ServiceFactory.java:196)<u></u><u></u></p>
<p class="MsoNormal"> at com.tibco.amf.admin.cmdline.CLIRegistry.getService(CLIRegistry.java:181)<u></u><u></u></p>
<p class="MsoNormal"> at com.tibco.amf.admin.cmdline.Processor.process(Processor.java:104)<u></u><u></u></p>
<p class="MsoNormal"> at com.tibco.amf.admin.cmdline.Processor.processChildren(Processor.java:39)<u></u><u></u></p>
<p class="MsoNormal"> at com.tibco.amf.admin.cmdline.ant.AMXAdminTask.process(AMXAdminTask.java:362)<u></u><u></u></p>
<p class="MsoNormal"> at com.tibco.amf.admin.cmdline.ant.AMXAdminTask.execute(AMXAdminTask.java:280)<u></u><u></u></p>
<p class="MsoNormal"> at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)<u></u><u></u></p>
<p class="MsoNormal"> at sun.reflect.GeneratedMethodAccessor26.invoke(Unknown Source)<u></u><u></u></p>
<p class="MsoNormal"> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)<u></u><u></u></p>
<p class="MsoNormal"> at java.lang.reflect.Method.invoke(Method.java:497)<u></u><u></u></p>
<p class="MsoNormal"> at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)<u></u><u></u></p>
<p class="MsoNormal"> ... 35 more<u></u><u></u></p>
<p class="MsoNormal">[2015-05-07 14:46:39,063] [JavaFX Application Thread] INFO griffon.javafx.JavaFXGriffonApplication - Shutdown is in process<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">My build.gradle<u></u><u></u></p>
<p class="MsoNormal">...<u></u><u></u></p>
<p class="MsoNormal">dependencies {<u></u><u></u></p>
<p class="MsoNormal"> griffon 'org.codehaus.griffon.plugins:griffon-miglayout-plugin:1.1.1'<u></u><u></u></p>
<p class="MsoNormal"> compile "org.codehaus.griffon:griffon-guice:${griffon.version}"
<u></u><u></u></p>
<p class="MsoNormal"> //compile 'org.apache.ant:ant:1.9.4'<u></u><u></u></p>
<p class="MsoNormal"> compile('org.apache.ant:ant-apache-log4j:1.9.4') {<u></u><u></u></p>
<p class="MsoNormal"> exclude group: 'log4j', module: 'log4j'<u></u><u></u></p>
<p class="MsoNormal"> }<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> runtime('log4j:log4j:1.2.17') {<u></u><u></u></p>
<p class="MsoNormal"> exclude group: 'ant', module: 'ant-nodeps'<u></u><u></u></p>
<p class="MsoNormal"> exclude group: 'ant', module: 'ant-junit'<u></u><u></u></p>
<p class="MsoNormal"> exclude group: 'ant-contrib', module: 'ant-contrib'<u></u><u></u></p>
<p class="MsoNormal"> }<u></u><u></u></p>
<p class="MsoNormal"> runtime 'org.slf4j:slf4j-log4j12:1.7.10'<u></u><u></u></p>
<p class="MsoNormal"> //runtime 'org.slf4j:slf4j-jcl:1.7.10'<u></u><u></u></p>
<p class="MsoNormal"> //runtime 'org.slf4j:jcl-over-slf4j:1.7.10'<u></u><u></u></p>
<p class="MsoNormal"> runtime 'commons-logging:commons-logging:1.1.1'<u></u><u></u></p>
<p class="MsoNormal"> runtime 'org.apache.ant:ant-commons-logging:1.9.4'<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"> testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'<u></u><u></u></p>
<p class="MsoNormal"> testCompile 'com.jayway.awaitility:awaitility-groovy:1.6.3'<u></u><u></u></p>
<p class="MsoNormal">}<u></u><u></u></p>
<p class="MsoNormal">...<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">My interpretation of this exception is:<u></u><u></u></p>
<p><u></u><span>1.<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>SLF4JLocationAwareLog has been loaded from slf4j<1.6 (i.e. jcl-over-slf4j-1.5.2.jar)<u></u><u></u></p>
<p><u></u><span>2.<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>LocationAwareLogger has been loaded from slf4j>=1.6 (i.e. slf4j-api-1.7.10.jar)<u></u><u></u></p>
<p><u></u><span>3.<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>I understand that slf4j isn’t binary compatible between 1.5 and 1.6 – and doesn’t like >1 binding on the classapath<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">What I don’t understand is if my Griffon/Gradle build project contains { runtime 'org.slf4j:slf4j-log4j12:1.7.10' } this means I’ve fulfilled slf4j’s requirement by providing the slf4j api and log4j12 binding.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">So ant’s taskdef classpath contains the 1.5.2 API – but I can’t change these scripts<u></u><u></u></p>
<p class="MsoNormal">For some reason slf4j picks jcl-over-slf4j-1.5.2 (the other choice being slf4j-log4j12-1.5.2) even though a binding has already been defined/loaded/used.<u></u><u></u></p>
<p class="MsoNormal">In the interim I can “make the error go away” by:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p><u></u><span>a)<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>Comment out runtime 'org.slf4j:slf4j-log4j12:1.7.10' – meaning no logging / noop?<u></u><u></u></p>
<p><u></u><span>b)<span style="font:7.0pt "Times New Roman"">
</span></span><u></u>Comment in runtime ‘org.slf4j:jcl-over-slf4j:1.7.10’ – (I don’t really want JCL)<u></u><u></u></p>
<p><u></u> <u></u></p>
<p class="MsoNormal">I’m running out of ideas– do I need to dig into the ant code & try and change the classpath (remove 1.7.10?) I don’t know if that would work if classes from 1.7.10 have already been loaded – I’m hoping there’s a really simple solution I’ve
just happened to overlook (like executing ant in a new process with a new classloader) but if anyone has a suggestion it would be appreciated.
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Cheers,<u></u><u></u></p>
<p class="MsoNormal">Paul<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<font face="Courier New" size="2">
<p><br>**********************************************************************<br>This
message is intended for the addressee named and may contain <br>privileged
information or confidential information or both. If you <br>are not the intended
recipient please delete it and notify the
sender.<br>**********************************************************************
</p></font>
</div>
<br>_______________________________________________<br>
slf4j-user mailing list<br>
<a href="mailto:slf4j-user@qos.ch">slf4j-user@qos.ch</a><br>
<a href="http://mailman.qos.ch/mailman/listinfo/slf4j-user" target="_blank">http://mailman.qos.ch/mailman/listinfo/slf4j-user</a><br></blockquote></div><br></div>