Tencent on-demand api exception

Recently, I started tomcat in eclipse to publish a web service, and the following exception occurred when using Tencent on-demand api in the web service:

 java.security.NoSuchAlgorithmException: Algorithm HmacSHA, it is normal to run directly in eclipse project and start tomcat directly in cmd. There are some solutions on the Internet, but there is no final solution. The engineering test code is as follows:

try {
			Mac mac = Mac.getInstance("HmacSHA1");
			System.out.println(mac.getAlgorithm());
		} catch (NoSuchAlgorithmException e) {
			// TODO auto-generated catch block
			e.printStackTrace ();
		}

 

, some say add java.security.Security.addProvider(new SunJCE()); and copy JAVA_HOME/ jre\lib\ext\sunjce_provider.jar to the tomcat container before calling the above code, and it seems that it all failed. Finally, check that there is a ${java.home} in the catalina.policy file in the servers directory of the eclipse project, so I edited the tomcat startup configuration properties in eclipse, and set the environment variable: java.home=xxx, which can be used normally, and finally found that it is actually Environment variable configuration problem.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326905187&siteId=291194637