Logger mismatch in sonar-python

22 views
Skip to first unread message

xti...@gmail.com

unread,
Apr 27, 2018, 5:59:00 PM4/27/18
to SonarQube
Hello fellows, 

After extending the sonar-python plugin and using sonar-plugin-api, when the new plugin is executed:


15:59:40.011 ERROR: Error during SonarQube Scanner execution
java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of 
org/sonar/classloader/ClassRealm) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of org/sonarsource/scanner/api/internal/IsolatedClassloader) for the method's 
defining class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type org/slf4j/ILoggerFactory used in the signature
at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:418)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:357)
at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:383)
at org.sonar.plugins.python.PythonReportSensor.<clinit>(PythonReportSensor.java:36)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.picocontainer.injectors.AbstractInjector.newInstance(AbstractInjector.java:145)
at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:342)
at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
at org.picocontainer.DefaultPicoContainer.getLocalInstance(DefaultPicoContainer.java:606)
at org.picocontainer.DefaultPicoContainer.getComponents(DefaultPicoContainer.java:587)
at org.sonar.core.platform.ComponentContainer.getComponentsByType(ComponentContainer.java:274)
at org.sonar.scanner.bootstrap.ScannerExtensionDictionnary.completeBatchExtensions(ScannerExtensionDictionnary.java:148)


checking the code of the class, it uses:

 private static final Logger LOG = LoggerFactory.getLogger(PythonReportSensor.class);


meanwhile other classes like PythonScanner uses the Logger LOG = Loggers.get(PythonScanner.class);

the first one comes from org.slf4j., but the second one comes from org.sonar.api.utils.log.Logger and import org.sonar.api.utils.log.Loggers;

maybe underneath them, they use the same library, but not the same version causing this kind of issues :(


Any posible solution, or suggestion?


Cristian




alban....@sonarsource.com

unread,
Apr 30, 2018, 3:50:15 AM4/30/18
to SonarQube
Hi Cristian,

If the plugin works before you extend it and not after, it's probably a dependency version issue or dependency packaging issue.
sonar-plugin-api provides a logger (org.sonar.api.utils.log.Logger), so we don't need the SLF4J one.
I created a ticket to get rid of SLF4J: SONARPY-281

Thanks for your feedback,

Alban
Reply all
Reply to author
Forward
0 new messages