2

I'm writing a program that uses the Twitter4J API to read and respond to tweets on Twitter. So far the program seems to run perfectly on my Acer Aspire 5734Z in both Windows 7 Home Premium 64 Bit and in Arch Linux 64 Bit. However, when I run the same exact program on my Raspberry Pi running Raspbian I encounter the following error:

Jan 04, 2014 12:34:16 AM twitter4j.TwitterStreamImpl info
INFO: java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: Default, provider: SunJSSE, class: sun.security.ssl.SSLContextImpl$DefaultSSLContext)
Jan 04, 2014 12:34:16 AM twitter4j.TwitterStreamImpl info
INFO: Waiting for 250 milliseconds

EDIT: Hold on, weird timestamps, let me check that my Raspberry Pi's time is set right.

EDIT: Nope, that didn't fix it.

AgentOrange96
  • 79
  • 1
  • 8
  • 1
    Have you verified that the program you have written and the jre on the pi are the same? If not one of them needs to be changed. – Kyle Jan 04 '14 at 00:38
  • They are both 1.7 However I do notice my laptop (Arch) is 1.7.0_45 and the Pi is 1.7.0_25 – AgentOrange96 Jan 04 '14 at 00:43
  • 3
    For some encryption algorithms Java relies on the underlying support of the platform, and if that's not there then you're out of luck. – Hot Licks Jan 04 '14 at 00:46
  • So, what do you mean by that? It would be good to note that at one point I did have another program using twitter4j running on this pi, but I have since reinstalled Raspbian AND I am using twitter4j in a different more efficient way, but I think it authenticates the same way. IDK what else would have changed. – AgentOrange96 Jan 04 '14 at 00:49
  • Alright then that shouldn't have any effect. I would check out what @HotLicks said. There may be a library you can download on the pi to help. – Kyle Jan 04 '14 at 00:50
  • I don't really understand what @HotLicks said though. :/ – AgentOrange96 Jan 04 '14 at 00:50
  • Basically if the pi/os can't do the encryption it won't work. Which is a possible problem. The reason for this derivation is that your error log is pointing to the fact that it doesn't know what algorithm is or how to use it. – Kyle Jan 04 '14 at 00:52
  • None of the actual encryption logic is written in Java but rather one form or another of a "native method", and hence the encryption code is not inherently portable between disparate platforms. Further, encryption code cannot be "exported" without a license, so likely the Oracle code always invokes OS services for encryption. If the OS doesn't have the service then it's not going to be available. – Hot Licks Jan 04 '14 at 01:00
  • Soo... how would I get this program to run? This seems convoluted. Like is there something I have to install on the Pi or would I have to export it differently? – AgentOrange96 Jan 04 '14 at 01:10
  • It may be that a different version of the Pi OS will support this -- there may be one version for export and another for use only inside the US, eg. Or perhaps you can change the specific algorithm you request, to use one that's more generally available. – Hot Licks Jan 04 '14 at 02:45

2 Answers2

0

This is most likely a setup problem, although it may be a missing library, I've not seen this problem myself so can't do much for you but I did do some googling and found a couple of similar questions answered here that may help:

Java and SSL - java.security.NoSuchAlgorithmException

Using a self generated key to test java ssl app

Community
  • 1
  • 1
Tim B
  • 40,716
  • 16
  • 83
  • 128
0

I had a similar problem with an application i wrote. It did not work with the oldrr java version 25 but with 45 and simply updating fixed the problem. Maybe that will fix it here, too since some things changed between these versions.

Marenthyu
  • 165
  • 1
  • 12
  • This could very well be it. The problem is the Raspbian repos don't seem to have 45 but only 25. :( – AgentOrange96 Jan 04 '14 at 23:31
  • So I did a little bit of googling and found this line of code: sudo apt-get update && sudo apt-get install oracle-java7-jdk - maybe this will update it ? – Marenthyu Jan 05 '14 at 02:10
  • Check this http://stackoverflow.com/questions/20780018/fail-to-update-jdk1-7-0-45-in-raspberry-pi – Marenthyu Jan 05 '14 at 02:12
  • 1
    I think it's using openjdk rather than Oracle's. So now I just need to figure out how to switch that. – AgentOrange96 Jan 05 '14 at 22:44
  • 1
    http://stackoverflow.com/questions/10401776/newbie-on-debian-and-trying-to-make-java-7-the-default-java-version-used Success! It's only 40 rather than 45 but it works anyway! :D – AgentOrange96 Jan 05 '14 at 22:47