Bug 828644 - slf4j/api.jar should not include org.slf4j.impl.StaticLoggerBinder
Summary: slf4j/api.jar should not include org.slf4j.impl.StaticLoggerBinder
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: slf4j
Version: 6.2
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: rc
: ---
Assignee: Mikolaj Izdebski
QA Contact: Miroslav Hradílek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-06-05 05:53 UTC by Sean Flanigan
Modified: 2012-09-07 10:49 UTC (History)
2 users (show)

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.
Clone Of:
Environment:
Last Closed: 2012-09-07 10:49:06 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 831933 1 None None None 2021-01-20 06:05:38 UTC
Red Hat Product Errata RHBA-2012:1239 0 normal SHIPPED_LIVE slf4j bug fix update 2012-09-07 14:47:41 UTC

Internal Links: 831933

Description Sean Flanigan 2012-06-05 05:53:42 UTC
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 10:49:06 UTC
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.