unable to start wiremock due to the following erro...
# help
j
unable to start wiremock due to the following error:
Copy code
2023-11-18 11:54:17.196 Verbose logging enabled
Exception in thread "main" wiremock.com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "mappings" (class com.github.tomakehurst.wiremock.stubbing.StubMapping), not marked as ignorable (10 known properties: "response", "requiredScenarioState", "priority", "persistent", "id", "postServeActions", "request", "newScenarioState", "uuid", "scenarioName"])
 at [Source: {
    "mappings": [
        {
            "name": "get-cif",
            "request": {
                "method": "POST",
                "urlPathPattern": "/cif"
            },
            "response": {
                "status": 200,
                "jsonBody": {
                    "success": true,
                    "data": {
                        "cifNumber": "1234567890"
                    },
                    "status_code": 200
                }
            }
        }
    ]
}
; line: 2, column: 18] (through reference chain: com.github.tomakehurst.wiremock.stubbing.StubMapping["mappings"])
        at wiremock.com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:51)
        at wiremock.com.fasterxml.jackson.databind.DeserializationContext.reportUnknownProperty(DeserializationContext.java:836)
        at wiremock.com.fasterxml.jackson.databind.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:1045)
        at wiremock.com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownProperty(BeanDeserializerBase.java:1352)
        at wiremock.com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1330)
        at wiremock.com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:262)
        at wiremock.com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:125)
        at wiremock.com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3702)
        at wiremock.com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2714)
        at com.github.tomakehurst.wiremock.common.Json.read(Json.java:39)
        at com.github.tomakehurst.wiremock.stubbing.StubMapping.buildFrom(StubMapping.java:69)
        at com.github.tomakehurst.wiremock.standalone.JsonFileMappingsSource.loadMappingsInto(JsonFileMappingsSource.java:79)
        at com.github.tomakehurst.wiremock.core.WireMockApp.loadMappingsUsing(WireMockApp.java:152)
        at com.github.tomakehurst.wiremock.core.WireMockApp.loadDefaultMappings(WireMockApp.java:148)
        at com.github.tomakehurst.wiremock.core.WireMockApp.<init>(WireMockApp.java:86)
        at com.github.tomakehurst.wiremock.WireMockServer.<init>(WireMockServer.java:69)
        at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.run(WireMockServerRunner.java:65)
        at com.github.tomakehurst.wiremock.standalone.WireMockServerRunner.main(WireMockServerRunner.java:113)
o
Hmm, did you export this file from somewhere? Mappings are normally a top-level array
t
Which version of WireMock are you running?
j
facing this error on any version >2.26 and <3
t
OK, the multiple mappings file format was introduced late in 2.x. Best bet is to upgrade to the latest 3.x
184 Views