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>