0

I wrote a simple JMS 2.0 client that is based on the Wildfly 10 JMS client libraries. When using SLF4J I get the following well-known error message:

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 usually indicates that a SLF4J bridge is missing. I observed that the maven dependency wilfly-jms-client-bom:10.0.0.0.Final also includes the dependencies slf4j-api:1.7.7.jbossorg-1 and jcl-over-slf4j:1.7.7.jbossorg-1. Although these dependencies should find their way to the classpath I get the before mentioned error.

SLFJ is also used by Wildfly components. My problem originated in a JNDI lookup for the remote JMS connection factory

ConnectionFactory connectionFactory = 
  (ConnectionFactory) namingContext.lookup("jms/RemoteConnectionFactory");

The described behavior can also be observed in the Wildfly quick starter example helloworld-jms.

Below you can find the program and the corresponding pom.xml that reproduces the error (the complete maven project can be downloaded from here).

public class JmsClient {

  public static void main(String[] args) {
    org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(JmsClient.class);
    logger.trace("Hello");
  }
}

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>samples-jms</groupId>
    <artifactId>hello-jms</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <version.wildfly>10.0.0.Final</version.wildfly>
        <version.wildfly.maven.plugin>1.0.2.Final</version.wildfly.maven.plugin>
        <version.jar.plugin>2.2</version.jar.plugin>
        <version.exec.plugin>1.2.1</version.exec.plugin>

        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.source>1.8</maven.compiler.source>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.wildfly</groupId>
            <artifactId>wildfly-jms-client-bom</artifactId>
            <version>${version.wildfly}</version>
            <type>pom</type>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${version.exec.plugin}</version>
                <configuration>
                    <mainClass>samples.jms.JmsClient</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${version.jar.plugin}</version>
                <configuration>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.wildfly.plugins</groupId>
                <artifactId>wildfly-maven-plugin</artifactId>
                <version>${version.wildfly.maven.plugin}</version>
            </plugin>
        </plugins>
    </build>
</project>

1 Answers1

0

Well there is just the slf4j-api on the classpath, but no implementation. jcl-over-slf4j:1.7.7.jbossorg-1 does not help you as it is a replacement for Jakarta Commons Logging. Just add a binding, such as logback (and use logger.info(), not trace)

    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.1.6</version>
    </dependency>
user140547
  • 7,750
  • 3
  • 28
  • 80
  • Thanks. That was the point. I mixed up two concepts: `jcl-over-slf4j` is a bridging module that redirects calls to JCL. One the other hand one needs a binding, such as `logback-classic`, `slf4j-log4j12`, etc. A module conatining a binding was missing in my case. – Johann Heinzelreiter Mar 08 '16 at 19:47