Hi, When I’m trying to execute the test “WireMockC...
# wiremock-java
j
Hi, When I’m trying to execute the test “WireMockContainerExtensionTest -> testJSONBodyTransformer”, I get an error:
Copy code
...
Caused by: org.testcontainers.containers.ContainerLaunchException: Could not create/start container
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:553)
	at org.testcontainers.containers.GenericContainer.lambda$doStart$0(GenericContainer.java:344)
	at org.rnorth.ducttape.unreliables.Unreliables.retryUntilSuccess(Unreliables.java:81)
	... 23 more
Caused by: java.lang.IllegalStateException: Wait strategy failed. Container exited with code 1
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:523)
	... 25 more
Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for URL to be accessible (<http://localhost:49189/__admin/mappings> should return HTTP [200])
	at org.testcontainers.containers.wait.strategy.HttpWaitStrategy.waitUntilReady(HttpWaitStrategy.java:320)
	at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:52)
	at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:964)
	at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:490)
	... 25 more
...
It seems that the container is failing. The container logs look like this:
Copy code
Exception in thread "main" java.lang.ClassNotFoundException: com.ninecookies.wiremock.extensions.JsonBodyTransformer
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Unknown Source)
	at com.github.tomakehurst.wiremock.extension.ExtensionLoader$3.apply(ExtensionLoader.java:71)
	at com.github.tomakehurst.wiremock.extension.ExtensionLoader$3.apply(ExtensionLoader.java:67)
	at wiremock.com.google.common.collect.Iterators$6.transform(Iterators.java:829)
	at wiremock.com.google.common.collect.TransformedIterator.next(TransformedIterator.java:52)
	at wiremock.com.google.common.collect.TransformedIterator.next(TransformedIterator.java:52)
	at wiremock.com.google.common.collect.Maps.uniqueIndex(Maps.java:1391)
	at wiremock.com.google.common.collect.Maps.uniqueIndex(Maps.java:1353)
	at com.github.tomakehurst.wiremock.extension.ExtensionLoader.asMap(ExtensionLoader.java:40)
	at com.github.tomakehurst.wiremock.extension.ExtensionLoader.loadExtension(ExtensionLoader.java:32)
	at com.github.tomakehurst.wiremock.extension.ExtensionLoader.load(ExtensionLoader.java:36)
	at com.github.tomakehurst.wiremock.standalone.CommandLineOptions.buildExtensions(CommandLineOptions.java:378)
	at com.github.tomakehurst.wiremock.standalone.CommandLineOptions.<init>(CommandLineOptions.java:369)
	at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.run(WireMockServerRunner.java:49)
	at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.main(WireMockServerRunner.java:133)
Maybe I’m doing something wrong? To be honest, I’m not sure how this is working and what is expected…
o
Hi! Did you initialize the extension?
So basically you need to run
mvn clean compile
so that the extensions are downloaded https://github.com/wiremock/wiremock-testcontainers-java/blob/main/pom.xml#L140-L170
j
Ok, I see. Now all tests are running green. Thank you very much! I suspected all tests were running out of the box…
👍 1
o
They will do so if you use maven. If you use IDEs like IDEA they don't always implement all Maven calls as needed
👍 1
146 Views