:wave: Hello, team! I am having wiremock as a dock...
# wiremock-java
v
👋 Hello, team! I am having wiremock as a docker container. I have been struggling to add grpc extension to it in a docker-compose file so that I can use the grpc mock. My local folders are in the same folder of the docker-compose.yml file. I keep getting different error from Java. Could you guide me how to do this? Should I use standalone jar? Many thanks. wiremock: image: wiremock/wiremock:3.13.1-1 ports: - "9090:8080" # gRPC port volumes: - ./mappings:/home/wiremock/mappings - ./proto-descriptors:/home/wiremock/grpc - ./extensions/wiremock-grpc-extension-0.11.0.jar:/var/wiremock/extensions/wiremock-grpc-extension-0.11.0.jar command: [ "--port", "8080", "--verbose", "--root-dir", "/home/wiremock", "--extensions", "org.wiremock.grpc.GrpcExtensionFactory" ]
l
Hi, yes, I think you need to use the standalone grpc extension. Also, I think you shouldn't need to use the
"--extensions", "org.wiremock.grpc.GrpcExtensionFactory"
part because the extension uses java service loader. So long as it can be found on the classpath it should be loaded.
I think I put an example of this together locally. Let me see if I can upload it to github for you to reference
I have just pushed this repo for you to take a look at - https://github.com/leeturner/wiremock-standalone-grpc-example
Hopefully that is all pretty self explanatory but if not let me know
v
Many thanks, Lee. I will take try and let you know.
Hello Lee, appreciate your help on this. If I have docker compose defined with . in front of all volumes. I got below error. * Executing task: docker logs --tail 1000 -f a422ad01b1c7386e0c9cff0792924afdbf3948f53fb06fb1266cb7760fc8b8fb 2025-09-22 142847.725 Verbose logging enabled Exception in thread "main" com.github.tomakehurst.wiremock.standalone.MappingFileException: Error loading file /home/wiremock/./mappings/hello-grpc.json: Unrecognized field "grpc" (class com.github.tomakehurst.wiremock.matching.RequestPattern), not marked as ignorable at com.github.tomakehurst.wiremock.standalone.JsonFileMappingsSource.loadMappingsInto(JsonFileMappingsSource.java:126) at com.github.tomakehurst.wiremock.core.WireMockApp.loadMappingsUsing(WireMockApp.java:288) at com.github.tomakehurst.wiremock.core.WireMockApp.loadDefaultMappings(WireMockApp.java:282) at com.github.tomakehurst.wiremock.core.WireMockApp.<init>(WireMockApp.java:143) at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:68) at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.run(WireMockServerRunner.java:71) at wiremock.Run.main(Run.java:23) * Terminal will be reused by tasks, press any key to close it. If I remove the . in front of all volumes, it seems to work from my test script calling the mocked service. However, the wiremock container logs seems to be missing the grpc extension but have only default response-template and webhook. Is this a bug? version: 3.13.1 port: 8080 enable-browser-proxying: false disable-banner: false no-request-journal: false verbose: true extensions: response-template,webhook 2025-09-22 144045.866 Admin request received: [0000000:1] - GET /health Host: [localhost:8080] User-Agent: [curl/8.5.0] Accept: [/]
l
Hi, are you saying that you need the
.
in front of all of your volumes ? If the extension is loaded it should appear in the list:
Copy code
version:                      3.13.1
port:                         8080
enable-browser-proxying:      false
disable-banner:               false
no-request-journal:           false
verbose:                      true

extensions:                   grpc-client-factory,grpc-stub-transformer,grpc,response-template,webhook
Are you saying the gRPC request is successful even though the extension isn't reported as being loaded?
v
Hi Lee, if I put docker compose like below without . for all volumes container can start normally without error, but the extension was not loaded in the log. And I confirm I was testing a normal http mock rather than the grpc service. Sorry for the basics and confusion. wiremock: image: wiremock/wiremock:3.13.1-1-alpine ports: - "9090:8080" # gRPC port volumes: - /mappings:/home/wiremock/mappings - /proto-descriptors:/home/wiremock/grpc - /extensions:/var/wiremock/extensions entrypoint: [ "/docker-entrypoint.sh", "--verbose" ]
l
It is difficult to say what the issue is without seeing all the files you have in the different locations. Could you put a simple project together somewhere that reproduces the issue (GitHub maybe) so I can take a look ? Also, it looks like you are assuming wiremock runs on port 9090 but you are not telling wiremock to start on that port.
v
OK, I will try from my side and share with you. I am missing a lot of basics and work with gpt. Thanks for your patience.
l
Maybe it would be worth pulling down the example I uploaded and using that as your base. As far as I know that all loads correctly etc
🙌 1
v
Hi Lee. Yes, your example works perfectly on my local. I can see grpc extension in log and also container started without issue. I am not able to reproduce what was wrong from my side. I will try the test script and see if the grpc mock is working. Thank you very much.
👍 1
GRPC test works perfectly. Again, many thanks for your help. This example is very useful. GPT was making too much stories.
l
No problem at all. Glad you are up and running.
v
Hi @Lee Turner , I was using below 2 methods to change response in my web server mock test with wiremock if needed. Is it the same for gRPC mock? response = requests.post(f"{self._base_url}/__admin/mappings", json=mapping) bulk_payload = {"mappings": list(self._mappings.values())} response = requests.post(f"{self._base_url}/__admin/mappings/import", json=bulk_payload)
l
Yes, you can use the mappings endpoints to change the stubs just the same. You need to remember that your responses still need to conform to the structure of the proto messages otherwise an exception will be thrown
👍 1
v
Hello, Lee. I am mocking my real gRPC server. I found the .dsc home/wiremock/grpc folder is not making effect if I am calling gRPC using requests.post the same way as your example. As long as my requests.post matches mappings.json, wiremock will respond, even if I have the wrong .dsc file mounted to home/wiremock/grpc. Then what is the function of .dsc file in wiremock grpc extnesion? If I am initiating a real gRPC call from my test code like below, I will receive "Code: Unimplemented Message: No matching stub mapping found for gRPC request", even though I have the .dsc file generated from proto file monted to homt/wiremock/grpc. Could you help explain? async def query_channel_metadata( job_name: str, run_number: int, pass_code: str ) -> _schema.ReadMetadataResponse: request = _schema.ReadMetadataRequest() if job_name is not None: request.job_name = job_name if run_number is not None: request.run_number = run_number if pass_code is not None: request.pass_code = pass_code proto_req = _grpc_helpers.dataclass_to_protobuff( request, MaxwellChannel_pb2.ReadMetadataRequest() ) channel = grpc.aio.insecure_channel("localhost:9090") _stub_factory = MaxwellChannel_pb2_grpc.MaxwellChannelStub stub = _stub_factory(channel) metadata = ( ("client-id", "9OtCVlEODHMYKUYsrpk6"), ) response_coro = stub.QueryChannelMetadata( request=proto_req, metadata=metadata ) response = await response_coro log_request( await get_tracking_id_from_coro(response_coro), "QueryChannelMetadata" ) return response async def test_query_channel_metadata(): await query_channel_metadata( job_name="Job3", run_number=1, pass_code="log" )
l
Sorry, I am not sure I fully understand your issue. Could you explain the flow of what you are doing and what you are expecting to work and what isn't ?