Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" #133

Closed
ati90ati opened this issue Mar 17, 2019 · 12 comments
Closed

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" #133

ati90ati opened this issue Mar 17, 2019 · 12 comments

Comments

@ati90ati
Copy link

Hello,

I have detected a problem in the plugin after upgraded to a newer version from 1.6.9.

Task :spotbugsMain
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.

This problem occurs in the version 1.6.10 / 1.6.11 / 1.7.0.
It happens on Java 8 and Java 11 also.
Gradle used: 5.2.1
As I observed it happens only if I have a project with Spring Boot (so this error will be present in each project which uses Spring Boot).
NOTE: Even the latest version of Spring Boot uses 1.7.x for the slf4j-api dependency.

Maybe this problem occurred after upgrading to slf4j-api version 1.8.0-beta-x

I've created a sample project to reproduce the problem:
https://github.com/ati90ati/bugreport-spotbugs-gradle-plugin-logging
You can run it with this command: ./gradlew clean build -PenableSpotbugs --warning-mode all

I hope that this example helps to find a solution to the problem.

@noeliajimenezg
Copy link

Hi,
I'm facing the same issue on version 1.7.1
I guess it could be related to this dependency problem https://www.mkyong.com/java/log4j2-failed-to-load-class-org-slf4j-impl-staticloggerbinder/

@rpalcolea
Copy link
Contributor

Looks like this was introduced on 1.6.10 -> https://github.com/spotbugs/spotbugs-gradle-plugin/blob/1.6.10/src/main/java/com/github/spotbugs/SpotBugsPlugin.java#L189

Previously, no trace of sl4fj

@patrick-webs
Copy link

This problem is also happening for me.

It appears to be some interaction between the spring boot gradle plugin and this plugin.

I tried adding slf4j-api and logback-classic to the classpath used by Spotbugs but it did not fix the issue, not sure why.

@sunzihao128858
Copy link

add "org.slf4j:slf4j-nop:1.7.25" to the build.gradle

@MarcJose
Copy link

I tried that before but it did not help.

@pineman
Copy link

pineman commented Nov 24, 2019

Still a problem. Can confirm it's something related to the spring boot plugin. Here's my build.gradle for reference:

plugins {
	id 'application'
	id 'idea'
	id 'com.github.ben-manes.versions' version '0.27.0'
	id 'com.github.spotbugs' version '2.0.1'
	id 'pmd'

	id 'org.springframework.boot' version '2.2.1.RELEASE'
	id 'io.spring.dependency-management' version '1.0.8.RELEASE'
}

repositories {
	jcenter()
}

dependencies {
	implementation 'org.springframework.boot:spring-boot-dependencies:2.2.1.RELEASE'
	implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
}

version = '0.1.0-SNAPSHOT'
application {
	mainClassName = 'foo'
}

pmd {
	ruleSets = ['java-quickstart']
}
spotbugs {
	toolVersion = '4.0.0-beta4'
}

Versions:
javac 13.0.1

------------------------------------------------------------
Gradle 6.0.1
------------------------------------------------------------

Build time:   2019-11-18 20:25:01 UTC
Revision:     fad121066a68c4701acd362daf4287a7c309a0f5

Kotlin:       1.3.50
Groovy:       2.5.8
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          13.0.1 (Oracle Corporation 13.0.1+9)
OS:           Mac OS X 10.14.5 x86_64

@adityasrini
Copy link

adityasrini commented Dec 3, 2019

I am getting this with micronaut 1.3.0.M1. I also have spring's dependency management plugin. I'm not sure if that could be a culprit here since others are having issues with their spring plugins (well spring boot) as well.

here's a portion of my build.gradle

plugins {
  id "com.github.spotbugs" version "3.0.0"
  id "com.github.johnrengelman.shadow" version "5.2.0"
  id "io.spring.dependency-management" version "1.0.8.RELEASE"
  id "org.flywaydb.flyway" version "6.1.0"
}

ext {
  micronautVersion = '1.3.0.M1'
}

apply plugin: "application"
apply plugin: "java"
apply plugin: 'jacoco'

repositories {
  mavenLocal()
  mavenCentral()
  jcenter()
  maven { url "https://oss.jfrog.org/oss-snapshot-local" }
}

dependencyManagement {
  imports {
    mavenBom "io.micronaut:micronaut-bom:$micronautVersion"
  }
}

dependencies {
  annotationProcessor "io.micronaut:micronaut-inject-java"
  annotationProcessor "io.micronaut:micronaut-security"

  compileOnly "io.micronaut:micronaut-inject-java"
  compile "io.micronaut:micronaut-http-client"
  compile "io.micronaut:micronaut-http-server-netty"
  compile "io.micronaut:micronaut-inject"
  compile "io.micronaut:micronaut-runtime"
  compile "io.micronaut.configuration:micronaut-jdbc-hikari"
  compile "javax.annotation:javax.annotation-api:1.3.2"
  compile 'org.springframework:spring-jdbc:5.0.9.RELEASE'

  // view
  compile 'io.micronaut:micronaut-views'
  runtime 'org.thymeleaf:thymeleaf:3.0.11.RELEASE'

  // security
  compile "io.micronaut:micronaut-security"
  compile 'io.micronaut.configuration:micronaut-security-oauth2'
  compile 'io.micronaut:micronaut-security-jwt'
  compile 'io.micronaut:micronaut-session'
  compile 'io.micronaut:micronaut-security-session'

  testAnnotationProcessor "io.micronaut:micronaut-inject-java"
  testCompile "io.micronaut.test:micronaut-test-junit5"
  testCompile "io.micronaut.test:micronaut-test-spock"
  testCompile 'org.junit.jupiter:junit-jupiter-api:5.3.2'
  testCompile 'org.junit.jupiter:junit-jupiter-params:5.3.2'
  testCompile 'org.skyscreamer:jsonassert:1.5.0'
  testRuntime 'org.junit.jupiter:junit-jupiter-engine:5.3.2'

  runtime "ch.qos.logback:logback-classic:1.2.3"
  runtime 'org.postgresql:postgresql:42.2.5'
}

shadowJar {
  mergeServiceFiles()
}

@KengoTODA
Copy link
Member

Please try the latest version 4.0.x instead of 3.0.0.

@daggerok
Copy link

daggerok commented Mar 23, 2020

we cannot use > 2.0.0, because of multi-module mono-repo. how to fix that problem with gradle plugin 2.0.0?

@KengoTODA
Copy link
Member

Duplicate of #136

@KengoTODA KengoTODA marked this as a duplicate of #136 Jun 25, 2020
@KengoTODA
Copy link
Member

I'll close this duplicated issue. use #136 instead.

@eceeb
Copy link

eceeb commented Sep 26, 2023

still the same problem here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests