Bug 828644 - slf4j/api.jar should not include org.slf4j.impl.StaticLoggerBinder
slf4j/api.jar should not include org.slf4j.impl.StaticLoggerBinder
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: slf4j (Show other bugs)
6.2
Unspecified Linux
unspecified Severity medium
: rc
: ---
Assigned To: Mikolaj Izdebski
Miroslav Hradílek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-06-05 01:53 EDT by Sean Flanigan
Modified: 2012-09-07 06:49 EDT (History)
2 users (show)

See Also:
Fixed In Version: 1.5.8-8.el6
Doc Type: Bug Fix
Doc Text:
Cause: The slf4j packages contained a non-functional dummy API implementation which was not supposed to be used. Consequence: The dummy implementation was always selected instead of other implementations and UnsupportedOperationException was thrown. Fix: The dummy API implementation has been removed. Result: User-supplied implementation is now always chosen, and slf4j works as expected.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-09-07 06:49:06 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Sean Flanigan 2012-06-05 01:53:42 EDT
User-Agent:       Mozilla/5.0 (X11; Linux i686 (x86_64)) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5
Build Identifier: 

The presence of org.slf4j.impl.StaticLoggerBinder in slf4j api.jar causes warnings or a failure, depending on the classpath order.  Upstream slf4j-api.jar does not include this class.


Reproducible: Always

Steps to Reproduce:
Run a java program which uses slf4j, with /usr/share/java/slf4j/api.jar and (say) /usr/share/java/slf4j/simple.jar on the classpath.  HelloWorld will do:

1. create HelloWorld.java (from http://www.slf4j.org/manual.html):

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class HelloWorld {
  public static void main(String[] args) {
    Logger logger = LoggerFactory.getLogger(HelloWorld.class);
    logger.info("Hello World");
  }
}

2. javac -cp /usr/share/java/slf4j/api.jar HelloWorld.java
3. java -cp /usr/share/java/slf4j/api.jar:/usr/share/java/slf4j/simple.jar:. HelloWorld
4. java -cp /usr/share/java/slf4j/simple.jar:/usr/share/java/slf4j/api.jar:. HelloWorld

Actual Results:  
If api.jar is first in the classpath, an exception occurs with this message: 

This code should have never made it into the jar


If another slf4j binding (sample.jar) is ahead of api.jar, there is no exception, but slf4j outputs this warning:

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/share/java/slf4j/simple.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/share/java/slf4j/api.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.


Expected Results:  
It should just output this:
0 [main] INFO HelloWorld - Hello World

Version: slf4j-1.5.8-7.el6

The message "This code should have never made it into the jar" comes from the version of StaticLoggerBinder in api.jar.
Comment 8 errata-xmlrpc 2012-09-07 06:49:06 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-1239.html

Note You need to log in before you can comment on or make changes to this bug.