0

I have a class:

package com.clevergift.services.payment;

import com.github.woki.payments.adyen.model.*;
import com.google.gson.annotations.SerializedName;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.HashMap;
import java.util.Map;

@XmlRootElement
public class CGPaymentRequest {

    @SerializedName("amount")
    private Amount amount;

    @SerializedName("merchantAccount")
    private String merchantAccount;

    @SerializedName("reference")
    private String reference;

    @SerializedName("additionalData")
    private Map<String, String> additionalData = new HashMap<>();

    // THIS IS SUPPOSED TO SOLVE THE PROBLEM
    public CGPaymentRequest() {

    }

    public void setAdditionalData(Map<String, String> additionalData) {
        this.additionalData = additionalData;
    }

    public Map<String, String> getAdditionalData() {
        return additionalData;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public String getReference() {
        return reference;
    }

    public void setMerchantAccount(String merchantAccount) {
        this.merchantAccount = merchantAccount;
    }

    public String getMerchantAccount() {
        return merchantAccount;
    }

    public void setAmount(Amount amount) {
        this.amount = amount;
    }

    public Amount getAmount() {
        return amount;
    }
}

I'm hitting an API endpoint here:

    Client client = ClientBuilder.newClient();
    WebTarget webTarget
            = client.target(TESTING_PAYS_URL + "authorise");

    Invocation.Builder invocationBuilder
            = webTarget.request(APPLICATION_JSON_TYPE);

    PaymentResponse paymentResponse = invocationBuilder
            .post(Entity.entity(cgPaymentRequest, MediaType.APPLICATION_JSON), PaymentResponse.class);

This works absolutely fine locally.

In my build.gradle file I have:

// https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client
compile group: 'org.glassfish.jersey.core', name: 'jersey-client', version: '2.6'

Bizarrely, when I run this on AWS Elastic Beanstalk, I get the error:

org.glassfish.jersey.message.internal.WriterInterceptorExecutor: MessageBodyWriter not found for media type=application/json, type=class com.clevergift.services.payment.CGPaymentRequest, genericType=class com.clevergift.services.payment.CGPaymentRequest.

I tried this solution (adding an empty constructor) https://stackoverflow.com/a/33756603/1246159. Yet still get the same error.

I also tried adding:

// https://mvnrepository.com/artifact/org.glassfish.jersey.media/jersey-media-json-jackson
compile group: 'org.glassfish.jersey.media', name: 'jersey-media-json-jackson', version: '2.28'

Yet still getting the same error. Im not really sure what I can try next....

Mark
  • 4,428
  • 14
  • 60
  • 116

0 Answers0