0

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?

Chaosphere2112
  • 664
  • 7
  • 19
  • Are you importing the correct Base64 class? – Natix Jun 02 '12 at 21:21
  • import org.apache.commons.codec.binary.Base64; – Chaosphere2112 Jun 02 '12 at 21:23
  • 1
    Make sure the "Link with Editor" icon button at the top of the package explorer is pressed, and the 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. – JB Nizet Jun 02 '12 at 21:33
  • Is there a reason why you're creating a new instance of the class? The `decodeBase64()` method is static. – Michael Jun 02 '12 at 21:34
  • @Michael: URL-safe decoding, as per http://www.sergiy.ca/how-to-implement-facebook-oauth-2.0-app-authorization-process-in-java/ . I've been having issues with making the process work, so I'm trying to follow the tutorial as identically as possible. – Chaosphere2112 Jun 02 '12 at 22:05
  • 1
    @JBNizet: Ah, there we go. Looks like GWT includes a version of commons codec as well. How do I make it refer to the library that I included instead, though? – Chaosphere2112 Jun 02 '12 at 22:06
  • @JBNizet Figured it out, just needed to bump up commons codec in the build order. – Chaosphere2112 Jun 02 '12 at 22:09
  • @JBNizet Can you quickly write an answer to your question? That way, it makes it easier for others to see the solution. – Michael Jun 02 '12 at 22:13
  • @Michael: I just did it. – JB Nizet Jun 02 '12 at 22:16
  • @JBNizet Oh ok thanks. You have to mark it as the answer too. – Michael Jun 02 '12 at 22:16

2 Answers2

1

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.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • 1
    for people who might get difficulties in finding "Link with Editor" icon, check this link for screen shot http://www.mainelydesign.com/blog/view/best-eclipse-feature-link-with-editor – kitokid Jun 21 '12 at 07:03
0

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?

user3607195
  • 41
  • 1
  • 7
  • If you have a new question, please ask it by clicking the [Ask Question](http://stackoverflow.com/questions/ask) button. Include a link to this question if it helps provide context. – greg-449 Apr 29 '15 at 15:01