Caused by: java.lang.SecurityException: Cannot locate policy or framework files!
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
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1631)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.autowireResource(CommonAnnotationBeanPostProcessor.java:522)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.getResource(CommonAnnotationBeanPostProcessor.java:496)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor$ResourceElement.getResourceToInject(CommonAnnotationBeanPostProcessor.java:627)
at org.springframework.beans.factory.annotation.InjectionMetadata$InjectedElement.inject(InjectionMetadata.java:171)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:318)
... 647 more
Caused by: java.lang.ExceptionInInitializerError
at javax.crypto.JceSecurityManager.(JceSecurityManager.java:65)
at javax.crypto.Cipher.getConfiguredPermission(Cipher.java:2587)
at javax.crypto.Cipher.getMaxAllowedKeyLength(Cipher.java:2611)
at sun.security.ssl.CipherSuite$BulkCipher.isUnlimited(CipherSuite.java:533)
at sun.security.ssl.CipherSuite$BulkCipher.(CipherSuite.java:505)
at sun.security.ssl.CipherSuite.(CipherSuite.java:612)
at sun.security.ssl.SSLContextImpl.getApplicableCipherSuiteList(SSLContextImpl.java:293)
at sun.security.ssl.SSLContextImpl.access$100(SSLContextImpl.java:41)
at sun.security.ssl.SSLContextImpl$AbstractTLSContext.(SSLContextImpl.java:424)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:264)
at java.security.Provider$Service.getImplClass(Provider.java:1634)
at java.security.Provider$Service.newInstance(Provider.java:1592)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:236)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:164)
at javax.net.ssl.SSLContext.getInstance(SSLContext.java:156)
at org.apache.http.ssl.SSLContextBuilder.build(SSLContextBuilder.java:271)
at com.example.dmj.business.common.HttpClientManager.afterPropertiesSet(HttpClientManager.java:68)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$6.run(AbstractAutowireCapableBeanFactory.java:1679)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1676)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1627)
... 659 more
Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
at javax.crypto.JceSecurity.(JceSecurity.java:88)
... 681 more
Caused by: java.lang.SecurityException: Cannot locate policy or framework files!
at javax.crypto.JceSecurity.setupJurisdictionPolicies(JceSecurity.java:255)
at javax.crypto.JceSecurity.access$000(JceSecurity.java:48)
at javax.crypto.JceSecurity$1.run(JceSecurity.java:80)
at java.security.AccessController.doPrivileged(Native Method)
at javax.crypto.JceSecurity.(JceSecurity.java:77)
... 681 more
七月 21, 2021 10:21:08 下午 org.apache.coyote.AbstractProtocol start
Caused by: java.lang.SecurityException: Cannot locate policy or framework files!
究极原因是这个,没有加解密包的文件
- 文件真的没有
- 文件权限过高
加解密其他错误
1、出现Illegal key size or default parameters错误
1、查看key是否合规
2、检查加解密包是否符合jdk的版本要求,jdk7只能用jdk7的加解密包 md5信息如下
jdk1.7 MD5 (local_policy.jar) = 9dd69bcc7637d872121880c35437788d
jdk1.7 MD5 (US_export_policy.jar) = 3bb2e88a915b3cb003ca185357a92c16
jdk1.8 MD5 (local_policy.jar) = dabfcb23d7bf9bf5a201c3f6ea9bfb2c
jdk1.8 MD5 (US_export_policy.jar) = ef6e8eae7d1876d7f05d765d2c2e0529
不符合这一要求的肯定是有问题的的
2、javax.crypto.BadPaddingException: Given final block not properly padded
出现了这个错误且不是错误1的前提下,不要惶恐就是你解密的key有问题
替换完jar包需要重启项目
包位于 $JAVA_HOME/jre/lib/security/policy
下边.