Error message due to getDistanceMatrix Request

deals with computation of distance matrices
Post Reply
User avatar
Bernd Welter
Site Admin
Posts: 2574
Joined: Mon Apr 14, 2014 10:28 am
Contact:

Error message due to getDistanceMatrix Request

Post by Bernd Welter »

One of my customers faced the following error message while he tried to get a distance matrix from an xServer2:
  • I was testing api getDistanceMatrix by sending below request as per the documentation

    Code: Select all

    {
      "id": "1352f670-b601-4845-9669-4098368601e3"
    }
    
  • But it shows an error as shown below

    Code: Select all

    {
      "message": "Cannot construct instance of `com.ptvgroup.xserver.xdima.GetDistanceMatrixRequest` (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information\n at [Source: (org.apache.cxf.transport.http.AbstractHTTPDestination$1); line: 3, column: 1]",
      "errorLine": 3,
      "errorColumn": 1,
      "faultType": "com.ptvgroup.xserver.exceptions.InvalidRequestFault"
    }
So this is a quite generic message and I get asked for this very often because it happens in many requests:
  • The xDima2.GetDistanceMatrixRequest is an abstract class which you can't instanciate.
    Taken from the API doc of GetDistanceMatrixRequest
    Taken from the API doc of GetDistanceMatrixRequest
  • Instead you have to use one of it's derived child classes - in this case either GetDistanceMatrixByLocationsRequest or GetDistanceMatrixByRelationsRequest
  • For the JSON request this means that you have to qualify the type, e.g. the GetDistanceMatrixByLocationsRequest:

    Code: Select all

    {
      "id": "1352f670-b601-4845-9669-4098368601e3",
      "$type": "GetDistanceMatrixByLocationsRequest"
    }
  • This will then lead to the next obstacle: the specific class requires two attributes which are supposed to be given...

    Code: Select all

    {
      "faultInfo": {
        "$type": "InvalidValueFault",
        "hint": "Affects field 'startLocations' in 'GetDistanceMatrixByLocationsRequest'.",
        "parameter": "/GetDistanceMatrixByLocationsRequest/startLocations"
      },
      "message": "List must have at least 1 item(s) but was missing."
    }
  • So to get rid of this second error please ensure to provide all required parameters of the child class in use ;-)
This also happens in the following request types (just a selection - there may be even more): Bernd
Bernd Welter
Technical Partner Manager Developer Components
PTV Logistics - Germany

Bernd at... The Forum,LinkedIn, Youtube, StackOverflow
I like the smell of PTV Developer in the morning... :twisted:
Post Reply