views:

155

answers:

2

Hi,

I am trying an encryption-decryption code in java. When I am trying to run it with JDK and code in class with main method it is running fine. But when I am trying to run same code in Tomcat, tomcat is throwing exception:

java.security.NoSuchAlgorithmException: Algorithm HmacSHA256 not available.

Can anybody guide me to proper direction please?

Thank you.

A: 

You just be running a different JRE. Look at this page to tell you what is available in which one.

http://java.sun.com/javase/6/docs/technotes/guides/security/SunProviders.html

Romain Hippeau
Hello ThereI tried the the link and found the HmacSHA256 for JCE provider and I assume that tomcat by default take the JRE from local system's environment variables so I even used JCE.jar in tomcat's library but it still not worked. Could you please guide me how to make local library available or some third party library can be used instead.Thank You
la89ondevg
@user324929 Are you saying that you do not have the right JRE ? I would recommend installing a newer one, or change to an encryption that is supported. If you want to know how to add a JCE provider in Java I suggest you open another question on this site, that is not really my area of expertise.
Romain Hippeau
Hello There Thanks for your comment as you suggested I reconfigured the JRE setting (JRE_HOME) for tomcat and made war of my app by ant script so all libraries get included and it worked fine.Thank You
la89ondevg
@user324929 Can you pick the right answer for the question, and optionally mark it up if it fixed your problem ?
Romain Hippeau
A: 

Hello Everybody Here I'm answering my own question I posted above. The solution I think for the problem is that make sure that all settings of the server being used must be configured properly in my case it was JRE_HOME for apache tomcat I was using and properly include every libararies being used by servlets and classes (better way write a ant script so that it can be used for future with minor changes). Thank You

la89ondevg