NutzCN Logo
问答 HmacSHA1算法在容器中无法找到
发布于 1373天前 作者 luowenkun 1228 次浏览 复制 上一个帖子 下一个帖子
标签:

HmacSHA1算法在简单的main函数中可以正常运行,但是放到nutzboot中就无法找到
[DEBUG] 15:20:25.790 [main] org.nutz.ioc.impl.NutIoc - Get 'dao'<>
[DEBUG] 15:20:25.790 [main] org.nutz.ioc.aop.impl.DefaultMirrorFactory - Load class cn.wizzer.common.services.Sys_Dev_Message_Service without AOP
[DEBUG] 15:20:25.790 [main] org.nutz.ioc.impl.NutIoc - Get 'dao'<>
[DEBUG] 15:20:25.794 [main] org.nutz.service.EntityService - Get TypeParams for self : cn.wizzer.iot.model.SYS_DEV_MESSAGE
[DEBUG] 15:20:25.798 [main] org.nutz.ioc.impl.ScopeContext - Remove object 'amqpRecieve' from [app] [DEBUG] 15:20:25.799 [main] org.nutz.ioc.impl.ScopeContext - Remove object 'mainLauncher' from [app] [ERROR] 15:20:25.802 [main] org.nutz.boot.NbApp - something happen!!
org.nutz.ioc.IocException: IocBean[mainLauncher -> amqpRecieve] throw Exception when creating
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:153)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:241)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:271)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:161)
at cn.wizzer.MainLauncher.init(MainLauncher.java:47)
at cn.wizzer.MainLauncher$FM$init$cff301be46c87e2fbea60f4ef344bacb.invoke(MainLauncher.java)
at org.nutz.ioc.impl.ObjectMakerImpl$2.trigger(ObjectMakerImpl.java:181)
at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:89)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:141)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:241)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:271)
at org.nutz.ioc.impl.NutIoc.get(NutIoc.java:161)
at org.nutz.boot.NbApp.execute(NbApp.java:214)
at org.nutz.boot.NbApp.run(NbApp.java:182)
at cn.wizzer.MainLauncher.main(MainLauncher.java:34)
Caused by: java.lang.RuntimeException: java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available
at org.nutz.lang.Lang.wrapThrow(Lang.java:190)
at org.nutz.ioc.impl.ObjectMakerImpl$2.trigger(ObjectMakerImpl.java:183)
at org.nutz.ioc.weaver.DefaultWeaver.onCreate(DefaultWeaver.java:89)
at org.nutz.ioc.impl.ObjectMakerImpl.make(ObjectMakerImpl.java:141)
... 14 common frames omitted
Caused by: java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available
at javax.crypto.Mac.getInstance(Mac.java:181)
at cn.wizzer.iot.amqp.AmqpRecieve.doSign(AmqpRecieve.java:299)
at cn.wizzer.iot.amqp.AmqpRecieve.init(AmqpRecieve.java:148)
at cn.wizzer.iot.amqp.AmqpRecieve$FM$init$cff301be46c87e2fbea60f4ef344bacb.invoke(AmqpRecieve.java)
at org.nutz.ioc.impl.ObjectMakerImpl$2.trigger(ObjectMakerImpl.java:181)
... 16 common frames omitted
[INFO ] 15:20:25.806 [main] org.nutz.ioc.impl.NutIoc - org.nutz.ioc.impl.NutIoc@1576277927 is closing. startup date [21-02-17 15:20:23.265]

代码:
/**
* password签名计算方法,请参见上一篇文档:AMQP客户端接入说明。
*/
private static String doSign(String toSignString, String secret, String signMethod) throws Exception {
SecretKeySpec signingKey = new SecretKeySpec(secret.getBytes(), signMethod);
Mac mac = Mac.getInstance(signMethod);
mac.init(signingKey);
byte[] rawHmac = mac.doFinal(toSignString.getBytes());
return Base64.encodeBase64String(rawHmac);
}

3 回复

"容器中" 什么容器? docker吗?

简单的main函数就是对的,用nutzboot不对,看了网上说的很多是ext的路径问题

jdk版本问题吧

添加回复
请先登陆
回到顶部