7

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

A. Kootstra
  • 6,827
  • 3
  • 20
  • 43
yoyoalphax
  • 71
  • 1
  • 3

1 Answers1

4

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.

A. Kootstra
  • 6,827
  • 3
  • 20
  • 43
  • Thanks Kootstra, but looks still fail: MacBook-Pro:Wiremock Alpha$ java -jar wiremock-standalone-2.14.0.jar 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. ... – yoyoalphax Mar 06 '18 at 01:28
  • At [SO] we use comments to ask for clarifications on the given answer/question and use the corresponding [edit] functionality to update an answer or question. Can you please update your question with what you've tried, including code/command examples, and what you've observed? – A. Kootstra Mar 06 '18 at 06:43
  • Updated the answer to provide context and resolution for the issue. – A. Kootstra Mar 06 '18 at 15:46
  • Thanks Kootstra, works. But on MAC, should change ; to : – yoyoalphax Mar 07 '18 at 02:33
  • Created seperate examples for both Windows and Mac. If this is the solution to your issue, please mark this answer as the solution for others who have this problem. – A. Kootstra Mar 07 '18 at 08:09
  • Thanks, it works even with extension jar I write. Set my entrypoint to `java,-cp,libs/${wiremock.jar}:libs/${extension.jar}:libs/*,${wiremock.main.class},--extensions,${extension.class},....` and I see logs in console. – WesternGun Nov 19 '21 at 15:27
  • In case someone had same issue on Virtualbox Debian, replace the ; with : java -cp "slf4j-nop-1.7.9.jar:wiremock-jre8-standalone-2.32.0.jar" com.github.tomakehurst.wiremock.standalone.WireMockServerRunner --port 9999 --global-response-templating – learningBunny Mar 24 '22 at 18:55