1

I've got sonar configured in my buildfile, but I can not seem to resolve this logging error:

[sonar] Apache Ant(TM) version 1.8.3 compiled on February 26 2012
[sonar] Sonar Ant Task version: 1.3
[sonar] Loaded from: file:/home/liam/.m2/repository/org/codehaus/sonar-plugins/sonar-ant-task/1.3/sonar-ant-task-1.3.jar
[sonar] Sonar work directory: /home/liam/workspace/api-trunk/.sonar
[sonar] Sonar server: http://127.0.0.1:9000
[sonar] Sonar version: 3.6.1
E, [2013-07-16T14:11:27.014000 #4090] ERROR -- : Error instantiating 'sonar' task: java.lang.ClassCastException: org.slf4j.impl.SimpleLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext

Buildr aborted! Java::OrgApacheToolsAnt::BuildException : java.lang.ClassCastException: org.slf4j.impl.SimpleLoggerFactory cannot be cast to ch.qos.logback.classic.LoggerContext

Relevant part of dependencies:

'org.slf4j:jcl-over-slf4j:jar:1.7.5',
'org.slf4j:log4j-over-slf4j:jar:1.7.5',
'org.slf4j:slf4j-api:jar:1.7.5',
'org.slf4j:slf4j-simple:jar:1.7.5',

I would like to give sonar a try, but I can't figure out any way to resolve this. There are similar bits on other threads, but they seem to just want the api or logback. We're primarily logging through log4j, and have the commons bindings. Is there some way to at least figure out what I'm doing wrong? I'm not getting any other issues with multiple bindings, and this is not giving me anything else to go on.

liam
  • 3,830
  • 6
  • 32
  • 31

1 Answers1

2

Possibly SONAR-3979, although that seems to be a Maven integration issue...

Are you certain a logback jar is not also on the classpath? You could try and omit the slf4j-simple log implementation jar and see what happens.

Update

Your Sonar ANT version 2.1 is two years old, whereas you Sonar Sonar version is very modern. Have you tried upgrading the jar? Can be retrieved from Maven Central with all its dependencies.

I understand that the issue is most likely a client classpath problem, but I just noticed that you're running this using Buildr? Could there be a logging jar being added to the classpath? This would be similar to the Maven issue above where Sonar was clashing with the logging implementation provided by the build tool. Again try removing the "slf4j-simple" jar.

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • I came across this issue before posting here. Its similar, but I don't think related. I've pulled all the transitive references out of my project dependencies, and actually looked up the version in the plugin that the sonar-ant-plugin depends on, and made sure that everything was using the same version. Compared it with the .sonar/batch/ set of libs and can't find _anything_ conflicting. – liam Jul 19 '13 at 00:13
  • I have done that. I have removed slf4j simple. I've tried it with logback classic. I've tried matching library numbers, and quite a few other things. This is an issue with buildr, and I am trying to run stuff through buildr to not reintroduce ant-file dependencies. I just can't get the main plug-in to work as documented (while their cobertura, junit, jdepend, etc plug-ins work as advertised). I just can't get this one to work and its not giving me much insight as to why it isn't working. Anyway, thanks for your input. – liam Jul 19 '13 at 20:18