签名文件打包错误java.io.IOException:Invalid keystore format

1.记录一下错误:

 1 java.lang.IllegalStateException: Failed to load ApplicationContext
 2 
 3     at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:125)
 4     at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108)
 5     at org.springframework.test.context.web.ServletTestExecutionListener.setUpRequestContextIfNecessary(ServletTestExecutionListener.java:190)
 6     at org.springframework.test.context.web.ServletTestExecutionListener.prepareTestInstance(ServletTestExecutionListener.java:132)
 7     at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246)
 8     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:227)
 9     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner$1.runReflectiveCall(SpringJUnit4ClassRunner.java:289)
10     at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
11     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.methodBlock(SpringJUnit4ClassRunner.java:291)
12     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:246)
13     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:97)
14     at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
15     at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
16     at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
17     at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
18     at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
19     at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
20     at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)
21     at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
22     at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:190)
23     at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
24     at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
25     at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
26     at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
27     at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
28 Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authorizationServerConfig': Unsatisfied dependency expressed through field 'jwtAccessTokenConverter'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtAccessTokenConverter' defined in class path resource [com/xuecheng/auth/config/AuthorizationServerConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Circular reference involving containing bean 'authorizationServerConfig' - consider declaring the factory method as static for independence from its containing instance. Factory method 'jwtAccessTokenConverter' threw exception; nested exception is java.lang.IllegalStateException: Cannot load keys from store: class path resource [xc.keystore]
29     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587)
30     at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91)
31     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373)
32     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1344)
33     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:578)
34     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)
35     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
36     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
37     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
38     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
39     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)
40     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
41     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
42     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
43     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
44     at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
45     at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:138)
46     at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99)
47     at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117)
48     ... 24 more
49 Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtAccessTokenConverter' defined in class path resource [com/xuecheng/auth/config/AuthorizationServerConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Circular reference involving containing bean 'authorizationServerConfig' - consider declaring the factory method as static for independence from its containing instance. Factory method 'jwtAccessTokenConverter' threw exception; nested exception is java.lang.IllegalStateException: Cannot load keys from store: class path resource [xc.keystore]
50     at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:587)
51     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1250)
52     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1099)
53     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:541)
54     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)
55     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
56     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
57     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
58     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
59     at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251)
60     at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
61     at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065)
62     at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584)
63     ... 42 more
64 Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Circular reference involving containing bean 'authorizationServerConfig' - consider declaring the factory method as static for independence from its containing instance. Factory method 'jwtAccessTokenConverter' threw exception; nested exception is java.lang.IllegalStateException: Cannot load keys from store: class path resource [xc.keystore]
65     at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185)
66     at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:579)
67     ... 54 more
68 Caused by: java.lang.IllegalStateException: Cannot load keys from store: class path resource [xc.keystore]
69     at org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory.getKeyPair(KeyStoreKeyFactory.java:67)
70     at com.xuecheng.auth.config.AuthorizationServerConfig.jwtAccessTokenConverter(AuthorizationServerConfig.java:95)
71     at com.xuecheng.auth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$417edd2f.CGLIB$jwtAccessTokenConverter$6(<generated>)
72     at com.xuecheng.auth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$417edd2f$$FastClassBySpringCGLIB$$e3d51f90.invoke(<generated>)
73     at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
74     at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
75     at com.xuecheng.auth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$417edd2f.jwtAccessTokenConverter(<generated>)
76     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
77     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
78     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
79     at java.lang.reflect.Method.invoke(Method.java:498)
80     at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
81     ... 55 more
82 Caused by: java.io.FileNotFoundException: class path resource [xc.keystore] cannot be opened because it does not exist
83     at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180)
84     at org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory.getKeyPair(KeyStoreKeyFactory.java:57)
85     ... 66 more

 第一次看会以为是

xc.keystore 文件不存在。 然而实际是有的 ,后来反复找问题:
Caused by: java.lang.IllegalStateException: Cannot load keys from store: class path resource [xc.keystore]
	at org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory.getKeyPair(KeyStoreKeyFactory.java:67)
	at com.xuecheng.auth.config.AuthorizationServerConfig.jwtAccessTokenConverter(AuthorizationServerConfig.java:95)
	at com.xuecheng.auth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$3dbf9bfd.CGLIB$jwtAccessTokenConverter$5(<generated>)
	at com.xuecheng.auth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$3dbf9bfd$$FastClassBySpringCGLIB$$4f2cadad.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
	at com.xuecheng.auth.config.AuthorizationServerConfig$$EnhancerBySpringCGLIB$$3dbf9bfd.jwtAccessTokenConverter(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
	... 55 more
Caused by: java.io.IOException: Invalid keystore format
	at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:663)
	at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:56)
	at sun.security.provider.KeyStoreDelegator.engineLoad(KeyStoreDelegator.java:224)
	at sun.security.provider.JavaKeyStore$DualFormatJKS.engineLoad(JavaKeyStore.java:70)
	at java.security.KeyStore.load(KeyStore.java:1445)
	at org.springframework.security.oauth2.provider.token.store.KeyStoreKeyFactory.getKeyPair(KeyStoreKeyFactory.java:57)
	... 66 more

  

 Invalid keystore format 格式不对,但是明明是可以用的。
解决办法

后来发现,IDEA的项目的jdk是1.8,我电脑环境是11,所有问题就来了,使用1.8的jdk生成keystore

  嗯成功!

 



posted @ 2022-01-08 17:21  亮sir  阅读(4558)  评论(2编辑  收藏  举报