Eclipse claims Commons-Codec methods don't exist

3.2k views Asked by At

I'm working on validating the signed_request parameter from the Facebook API, following these guidelines, but I'm running into issues calling some of the methods of the Base64 class from Commons Codec. I added the commons-codec 1.6 library to my project (picture of my referenced libraries), but Eclipse is showing

Constructor with red underline

and saying

Error message (Constructor Base64(boolean) is undefined)

which is odd, since this says otherwise.

I verified the md5 of the download, so that's not the issue.

Any bright ideas?

2

There are 2 answers

1
JB Nizet On BEST ANSWER

I suspect that you have another version of commons-codes classes in your classpath, before the commons-codec jar you installed.

Make sure the "Link with Editor" icon button at the top of the package explorer is pressed, and then ctrl-click on the Base64 type in your editor. Then check if the selected class file in the package editor is the class inside the commons-codec-1.6.jar, or if it's a class in another jar.

1
user3607195 On

I faced the same issue. It got resolved after I moved the codec jar in the build order. But I couldn't able to build the GWT project. It shows the following error

String key = new String(Base64.decodeBase64("xxxx"));

error: method decodeBase64 in class Base64 cannot be applied to given types; "actual argument String cannot be converted to byte[] by method invocation conversion".

The JRE still reads the codec package from GWT package. How to resolve this?