Caused by: java.lang.SecurityException: Cannot locate policy or framework files!

  1. framework.beans.factory.BeanCreationException: Error creating bean with name 'httpClientManager' defined in URL [jar:file:/data/project/erp_trades_sync/code/WEB-INF/lib/dmj-services-trades-support-1.112.1.jar!/com/example/dmj/business/common/HttpClientManager.class]: Invocation of init method failed; nested exception is java.lang.ExceptionInInitializerError
  2. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1631)
  3. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
  4. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
  5. at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
  6. at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  7. at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
  8. at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
  9. at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:522)
  10. at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496)
  11. at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:627)
  12. at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:171)
  13. at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
  14. at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:318)
  15. ... 647 more
  16. Caused by: java.lang.ExceptionInInitializerError
  17. at javax.crypto.JceSecurityManager.(JceSecurityManager.java:65)
  18. at javax.crypto.Cipher.getConfiguredPermission(Cipher.java:2587)
  19. at javax.crypto.Cipher.getMaxAllowedKeyLength(Cipher.java:2611)
  20. at sun.security.ssl.CipherSuite$BulkCipher.isUnlimited(CipherSuite.java:533)
  21. at sun.security.ssl.CipherSuite$BulkCipher.(CipherSuite.java:505)
  22. at sun.security.ssl.CipherSuite.(CipherSuite.java:612)
  23. at sun.security.ssl.SSLContextImpl.getApplicableCipherSuiteList(SSLContextImpl.java:293)
  24. at sun.security.ssl.SSLContextImpl.access$100(SSLContextImpl.java:41)
  25. at sun.security.ssl.SSLContextImpl$AbstractTLSContext.(SSLContextImpl.java:424)
  26. at java.lang.Class.forName0(Native Method)
  27. at java.lang.Class.forName(Class.java:264)
  28. at java.security.Provider$Service.getImplClass(Provider.java:1634)
  29. at java.security.Provider$Service.newInstance(Provider.java:1592)
  30. at sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
  31. at sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
  32. at javax.net.ssl.SSLContext.getInstance(SSLContext.java:156)
  33. at org.apache.http.ssl.SSLContextBuilder.build(SSLContextBuilder.java:271)
  34. at com.example.dmj.business.common.HttpClientManager.afterPropertiesSet(HttpClientManager.java:68)
  35. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$6.run(AbstractAutowireCapableBeanFactory.java:1679)
  36. at java.security.AccessController.doPrivileged(Native Method)
  37. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1676)
  38. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1627)
  39. ... 659 more
  40. Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
  41. at javax.crypto.JceSecurity.(JceSecurity.java:88)
  42. ... 681 more
  43. Caused by: java.lang.SecurityException: Cannot locate policy or framework files!
  44. at javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:255)
  45. at javax.crypto.JceSecurity.access$000(JceSecurity.java:48)
  46. at javax.crypto.JceSecurity$1.run(JceSecurity.java:80)
  47. at java.security.AccessController.doPrivileged(Native Method)
  48. at javax.crypto.JceSecurity.(JceSecurity.java:77)
  49. ... 681 more
  50. 七月 21, 2021 10:21:08 下午 org.apache.coyote.AbstractProtocol start

Caused by: java.lang.SecurityException: Cannot locate policy or framework files!

究极原因是这个,没有加解密包的文件

  • 文件真的没有
  • 文件权限过高

加解密其他错误

  1. 1、出现Illegal key size or default parameters错误
  2. 1、查看key是否合规
  3. 2、检查加解密包是否符合jdk的版本要求,jdk7只能用jdk7的加解密包 md5信息如下
  4. jdk1.7 MD5 (local_policy.jar) = 9dd69bcc7637d872121880c35437788d
  5. jdk1.7 MD5 (US_export_policy.jar) = 3bb2e88a915b3cb003ca185357a92c16
  6. jdk1.8 MD5 (local_policy.jar) = dabfcb23d7bf9bf5a201c3f6ea9bfb2c
  7. jdk1.8 MD5 (US_export_policy.jar) = ef6e8eae7d1876d7f05d765d2c2e0529
  8. 不符合这一要求的肯定是有问题的的
  9. 2javax.crypto.BadPaddingException: Given final block not properly padded
  10. 出现了这个错误且不是错误1的前提下,不要惶恐就是你解密的key有问题
  11. 替换完jar包需要重启项目

包位于 $JAVA_HOME/jre/lib/security/policy 下边.