0

Recently had a problem with

java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available

Tried to isolate the problem, using this simple code:

import java.security.NoSuchAlgorithmException;

import javax.crypto.Mac;

public class Main {
  public static void main(String... args) {

      final String HMAC_SHA1_ALGORITHM = "HmacSHA1";
      Mac instance;
      try {
          instance = Mac.getInstance(HMAC_SHA1_ALGORITHM);
      } catch (NoSuchAlgorithmException e) {
          final String errmsg = "NoSuchAlgorithmException: "
                  + HMAC_SHA1_ALGORITHM + " " + e;
          // ...
      }

  }
}

The thing is that this works in one of my Eclipse instances, and not on the other. All tested using New Java Project, pasting the above, and running, so this should be due to some settings difference between the Eclipse instances.

I've tried to look through all the seemingly relevant settings (classpath, JRE, java compiler), but nothing that looks different or makes it work if changed. (If someone knows how to 'diff' the settings of two Eclipses, do tell!)

I'm resorting to simply using a third Eclipse (where it works (so far)), but it would still be interesting to learn what this potentially infuriating problem is really down to.

Jonas N
  • 1,757
  • 2
  • 21
  • 41
  • Possible instance of this?: http://stackoverflow.com/questions/2856248/nosuchalgorithmexception-algorithm-hmacsha1-not-available – jefflunt Sep 07 '12 at 13:24
  • Well I had read that question, and I suppose it's possibly related, but as that is started by a script ("The startup script...") I thought it would be different enough to not be relevant. I tried the 'addProvider()' part of it, made no difference. It would be extremely odd if the library was in some 'wrong place', I think. And it works in one of the Eclipses, so it should (but you never know) be something to do with Eclipse, I think. – Jonas N Sep 07 '12 at 14:08

1 Answers1

0

I had that same Exception using Eclipse and tomcat, what I did was :

Reload JDK over TOMCAT 8 configuration, and it started working

lsp
  • 161
  • 1
  • 2
  • 8