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

Running spotbugs 4.7.2 with -textui flag results in org.apache.logging.slf4j.SLF4JServiceProvider exception #2176

Closed
creesch opened this issue Sep 14, 2022 · 3 comments · Fixed by #2203

Comments

@creesch
Copy link

creesch commented Sep 14, 2022

See the below output, this is with openJDK 11, the issue is not present in 4.7.1

Unexpected problem occured during version sanity check
Reported exception:
java.lang.AbstractMethodError: Receiver class org.apache.logging.slf4j.SLF4JServiceProvider does not define or inherit an implementation of the resolved method 'abstract java.lang.String getRequestedApiVersion()' of interface org.slf4j.spi.SLF4JServiceProvider.
	at org.slf4j.LoggerFactory.versionSanityCheck(LoggerFactory.java:297)
	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:141)
	at org.slf4j.LoggerFactory.getProvider(LoggerFactory.java:421)
	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:407)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:356)
	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:382)
	at edu.umd.cs.findbugs.CheckBcel.<clinit>(CheckBcel.java:40)
	at edu.umd.cs.findbugs.LaunchAppropriateUI.launch(LaunchAppropriateUI.java:99)
	at edu.umd.cs.findbugs.LaunchAppropriateUI.main(LaunchAppropriateUI.java:198)
@welcome
Copy link

welcome bot commented Sep 14, 2022

Thanks for opening your first issue here! 😃
Please check our contributing guideline. Especially when you report a problem, make sure you share a Minimal, Complete, and Verifiable example to reproduce it in this issue.

@gtoison
Copy link
Contributor

gtoison commented Sep 14, 2022

This is most likely since the upgrade to slf4j 2.0 in #2156
Apparently there are some breaking changes between slf4j 1.x and 2.x
https://issues.apache.org/jira/browse/LOG4J2-3139

getRequesteApiVersion was renamed getRequestedApiVersion here:
qos-ch/slf4j@7483a11

I think you need a log4j2 bridge compatible with slf4j 2 but I'm not sure if it is released yet

@baloghadamsoftware
Copy link
Contributor

I thought that the fault was in my system.

dmivankov added a commit to dmivankov/spotbugs that referenced this issue Oct 5, 2022
Resolves spotbugs#2176
```
Unexpected problem occured during version sanity check
Reported exception:
java.lang.AbstractMethodError: Receiver class org.apache.logging.slf4j.SLF4JServiceProvider does not define or inherit an implementation of the resolved method 'abstract java.lang.String getRequestedApiVersion()' of interface org.slf4j.spi.SLF4JServiceProvider.
	at org.slf4j.LoggerFactory.versionSanityCheck(LoggerFactory.java:297)
...
```

The issue is log4j 2.x broke compatibility (renamed method that had a grammatic typo)
and slf4j-impl 2.18.0 still being on 1.x.

2.19.0 is now released with fix of
https://issues.apache.org/jira/browse/LOG4J2-3139

Changing `log4j-slf4j18-impl` to `log4j-slf4j2-impl`, see
https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/index.html

Adding explicit (runtime) dependency on log4j-core because
`log4j-slf4j2-impl` doesn't have it and it'd otherwise cause
```
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
```

Tested with
```console
$ rm ./spotbugs/.libs/*
$ gradle assemble
$ java -cp "./spotbugs/.libs/*:./spotbugs/build/libs/spotbugs.jar" edu.umd.cs.findbugs.LaunchAppropriateUI -textui
...log4j errors are not showing up now...
```
@dmivankov dmivankov mentioned this issue Oct 5, 2022
1 task
KengoTODA pushed a commit that referenced this issue Oct 7, 2022
Resolves #2176
```
Unexpected problem occured during version sanity check
Reported exception:
java.lang.AbstractMethodError: Receiver class org.apache.logging.slf4j.SLF4JServiceProvider does not define or inherit an implementation of the resolved method 'abstract java.lang.String getRequestedApiVersion()' of interface org.slf4j.spi.SLF4JServiceProvider.
	at org.slf4j.LoggerFactory.versionSanityCheck(LoggerFactory.java:297)
...
```

The issue is log4j 2.x broke compatibility (renamed method that had a grammatic typo)
and slf4j-impl 2.18.0 still being on 1.x.

2.19.0 is now released with fix of
https://issues.apache.org/jira/browse/LOG4J2-3139

Changing `log4j-slf4j18-impl` to `log4j-slf4j2-impl`, see
https://logging.apache.org/log4j/2.x/log4j-slf4j-impl/index.html

Adding explicit (runtime) dependency on log4j-core because
`log4j-slf4j2-impl` doesn't have it and it'd otherwise cause
```
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console...
```

Tested with
```console
$ rm ./spotbugs/.libs/*
$ gradle assemble
$ java -cp "./spotbugs/.libs/*:./spotbugs/build/libs/spotbugs.jar" edu.umd.cs.findbugs.LaunchAppropriateUI -textui
...log4j errors are not showing up now...
```
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

Successfully merging a pull request may close this issue.

3 participants