1

I am implementing GoCardless into my ColdFusion application by using their Java library and have encountered the following error:

java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String([B)Ljava/lang/String;

As explained in the GoCardless documentation their library is dependent upon the Apache Commons Codec library (amongst others). When I put the GoCardless JAR into my ColdFusion lib folder I noticed that the Apache Commons Codec JAR is already present and so am unsure what this error signifies.

Any help would be much appreciated. Thanks!

0

1 Answer 1

3

Assuming you are not invoking that method, it probably means exactly what it says. The codec version loaded by the jvm does not contain a method with that signature. You can verify it by creating an instance of org.apache.commons.codec.binary.Base64 class and checking the available methods with cfdump. (It might also be a class loader conflict, but the former is more likely.)

As far as the reason, when multiple versions of a jar are present in the class path, the jvm can only pick one of them. It probably picked the older version that ships with ColdFusion, which may not have that method. See: Identifying which jar a class was loaded from...

The simplest way to load a newer jar version is to remove the old jar in /lib, replace it with the newer version, and restart CF. Keep in mind that library is also used by CF itself, so you run the risk of breaking something if the newer version is not backward compatible. Another option is using CF10's dynamic class loading feature. It is basically a rip of Mark Mandel's JavaLoader.cfc, just bundled into CF.

Sign up to request clarification or add additional context in comments.

8 Comments

I just cfdumped org.apache.commons.codec.binary.Base64 and the method is available in the class being loaded from /lib
Does the signature match? Because unlike CF java supports overloaded methods. Also, you put them both in /lib ;-) So which file is it from - the older or newer one?
No I never put the newer one in /lib. The only version in there is the one which ships with ColdFusion. I had hoped it would work with this version.
Oh, my bad. It could still be that the older version does not contain the right method signature, so you may need to update. I am not near CF10 to check the methods. Can you update your question with a screen shot of the cfdump?
Actually my bad! Just noticed that it doesn't contain this method just a similarly named one.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.