I am integrating the square API with my online website built using Java and Maven. I downloaded the Square API and followed the ‘my first usage’ example in this URL:
After building the project and running the main method in the Example class it fails on line 32:
java.lang.NoSuchMethodError: com.squareup.square.ApiHelper$1.configOverride(Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/cfg/MutableConfigOverride;
at com.squareup.square.ApiHelper$1.(ApiHelper.java:47)
at com.squareup.square.ApiHelper.(ApiHelper.java:42)
at com.squareup.square.SquareClient.getBaseUri(SquareClient.java:568)
at com.squareup.square.SquareClient.getBaseUri(SquareClient.java:577)
at com.squareup.square.api.DefaultLocationsApi.buildListLocationsRequest(DefaultLocationsApi.java:93)
at com.squareup.square.api.DefaultLocationsApi.listLocations(DefaultLocationsApi.java:65)
Is anyone able to assist me as to why I am receiving this error? I have the latest dependency 8.1.0.20210121
as well as the Jackson dependencies that come with it.
Just an update: I have reverted back to a version of the Square API that doesn’t require Jackson dependencies and the examples work! However, the version used goes all the way back to square-3.3.0.20191217, is there a way around this for recent versions? I don’t want to be left behin din updates because my IDE won’t run Jackson dependencies.
SquareClient client = new SquareClient.Builder()
.environment(Environment.SANDBOX)
.accessToken("sandbox_access_token")
.build();
LocationsApi api = client.getLocationsApi();
try {
List<Location> locations = api.listLocations().getLocations();
System.out.println(locations.get(0).getId()); // just print first id to see if it works
...
If this is the same as yours, and still doesn’t work, it seems like something else is going wrong. Are you explicitly adding Jackson dependencies in your pom.xml?
Thank you for replying I really appreciate your hard work. From the research that I’ve done around this subject, it seems that the version of jackson-databind that contains configOverride is being overwritten by an incomplete version at some point a long the dependency path.
As to your code that is exactly what I am using to produce the error. A heads up that I am using Netbeans IDE and these are the dependencies I am currently running:
Thanks for sharing. Do you mind sharing the full list of dependencies from your pom.xml file? I’m also bringing this up with our SDK team to see if they have any thoughts.
I am running Glassfish Server 4.1.1, therein lies the problem. Glassfish has old versions of Jackson pre-installed on the server. It was a case of removing these versions through the modules folder and then replacing them with the most recent JAR files. I then updated the names of the downloaded JAR files so they were exactly the same as the old versions that were removed. This then allowed the dependencies to run without any errors.
I hope this helps anyone else using the Glassfish Server with Netbeans IDE and it may be something for the Square development team to think about if necessary at any point in the future.
I appreciate your support Stephen and I hope you have a great weekend.