Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get "Failed to load class org.slf4j.impl.StaticLoggerBinder" error when I run wiremock.jar on MAC

How about the case of running WireMock in the terminal with java -jar wiremock-standalone.jar? Shouldn't console logging be enabled?

Steps:

  1. I downloaded the jar from: http://repo1.maven.org/maven2/com/github/tomakehurst/wiremock-standalone/2.9.0/wiremock-standalone-2.9.0.jar

  2. Run it and got the error: error screenshot

  3. Check my java version and upgrade to the latest, but no help: java upgrade, but no help

like image 428
yoyoalphax Avatar asked Oct 16 '22 21:10

yoyoalphax


1 Answers

It looks to me that you're trying to start the specific class in a standalone manner. This won't work as WireMock depends on a lot of other classes/jars that are not part of this jar.

For this reason a seperate Stand alone version is released which can be downloaded here Maven Repository. Instructions on how to start this version can be found here WireMock userguide.

When starting the standalone version a standard error is shown that causes no functional issues:

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.

In order to remove this error download slf4j-nop-1.7.9.jar and place it in your class path. Alternatively put it next to your WireMock jar and adjust your command to this:

Windows example

java -cp "slf4j-nop-1.7.9.jar;wiremock-standalone-2.15.0.jar" com.github.tomakehurst.wiremock.standalone.WireMockServerRunner --port 9999 --global-response-templating

Mac example

java -cp "slf4j-nop-1.7.9.jar:wiremock-standalone-2.15.0.jar" com.github.tomakehurst.wiremock.standalone.WireMockServerRunner --port 9999 --global-response-templating

In your screenshot I see that you're running 2.9.0, whereas the current version is 2.15.0. I recommend upgrading wiremock to this version.

like image 175
A. Kootstra Avatar answered Oct 20 '22 23:10

A. Kootstra