bunq / sdk_java

Java SDK for bunq API
MIT License
47 stars 23 forks source link

ExceptionInInitializerError in ApiContext.create #127

Closed tbotting closed 4 years ago

tbotting commented 4 years ago

Tried bunq version 1.21.1, 1.13.0 and 1.13.1. All have the same issue since this morning. It used to work for weeks before this.

API_CONTEXT = ApiContext.create(ApiEnvironmentType.PRODUCTION, BUNQ_API_KEY, "Bunq Device");

is causing:

Exception in thread "main" java.lang.ExceptionInInitializerError Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $.director_alias at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:131) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:222) at com.google.gson.Gson.fromJson(Gson.java:927) at com.google.gson.Gson.fromJson(Gson.java:994) at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162) at com.bunq.sdk.json.SessionServerAdapter.deserialize(SessionServerAdapter.java:57) at com.bunq.sdk.json.SessionServerAdapter.deserialize(SessionServerAdapter.java:23) at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) at com.google.gson.Gson.fromJson(Gson.java:927) at com.google.gson.Gson.fromJson(Gson.java:994) at com.google.gson.Gson.fromJson(Gson.java:967) at com.bunq.sdk.model.core.BunqModel.fromJsonArrayNested(BunqModel.java:69) at com.bunq.sdk.model.core.SessionServer.create(SessionServer.java:78) at com.bunq.sdk.context.ApiContext.initializeSession(ApiContext.java:272) at com.bunq.sdk.context.ApiContext.initialize(ApiContext.java:225) at com.bunq.sdk.context.ApiContext.create(ApiContext.java:140) at com.bunq.sdk.context.ApiContext.create(ApiContext.java:122) at com.bunq.sdk.context.ApiContext.create(ApiContext.java:114) at com.payments.Bunq.<clinit>(Bunq.java:20) Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at path $.director_alias at com.google.gson.internal.bind.JsonTreeReader.expect(JsonTreeReader.java:162) at com.google.gson.internal.bind.JsonTreeReader.beginObject(JsonTreeReader.java:87) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215) ... 19 more

InhouseMedia commented 4 years ago

Having the same issue for the C# SDK. It's been 24 hours now!

Nayels commented 4 years ago

I've been experiencing the same issue since Tuesday. They made a change in the response of the Bunq API for the new Bunq +1 functionality.

Best would be to fork the SDK and change the director_alias

NilsTellow commented 4 years ago

@InhouseMedia @tbotting

As this is a breaking bug for some companies. I've made a fork that fixes the above problem. https://github.com/NilsTellow/sdk_java/ It can be pulled from JItpack. Same as Bunq SDK. https://jitpack.io/#NilsTellow/sdk_java

Keep in mind that this a temporary fix, as I do not know what they will change in the API for the bug fix.

angelomelonas commented 4 years ago

Hi everyone,

This issue has been resolved in the latest release (1.14.0). As @Nayels pointed out, a new field was added to the response and the SDKs have since been regenerated to accompany this change.

You can view the diff between 1.13.1 and 1.14.0 for the UserCompany.java endpoint here.