【Spring基础】Failed to read candidate component class错误分析

矫情吗;* 2022-07-15 04:11 271阅读 0赞

错误信息:

  1. - JSR-250 'javax.annotation.ManagedBean' found and supported for component scanning
  2. - Context initialization failed
  3. org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [E:\gold_work\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\gold_public\WEB-INF\classes\com\golddashi\base\thirdpay\rongbao\configure\RBService.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [E:\gold_work\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\gold_public\WEB-INF\classes\com\golddashi\base\thirdpay\rongbao\configure\RBService.class]; nested exception is java.lang.IllegalArgumentException
  4. at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:290)
  5. at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
  6. at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
  7. at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
  8. at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438)
  9. at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
  10. at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:185)
  11. at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)
  12. at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)
  13. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
  14. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
  15. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
  16. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
  17. at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
  18. at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
  19. at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
  20. at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
  21. at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
  22. at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
  23. at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
  24. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
  25. at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
  26. at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
  27. at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
  28. at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)
  29. at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
  30. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  31. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
  32. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
  33. at java.util.concurrent.FutureTask.run(Unknown Source)
  34. at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  35. at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  36. at java.lang.Thread.run(Unknown Source)
  37. Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [E:\gold_work\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\gold_public\WEB-INF\classes\com\golddashi\base\thirdpay\rongbao\configure\RBService.class]; nested exception is java.lang.IllegalArgumentException
  38. at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:56)
  39. at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
  40. at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
  41. at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:266)
  42. ... 32 more
  43. Caused by: java.lang.IllegalArgumentException
  44. at org.springframework.asm.ClassReader.<init>(Unknown Source)
  45. at org.springframework.asm.ClassReader.<init>(Unknown Source)
  46. at org.springframework.asm.ClassReader.<init>(Unknown Source)
  47. at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:53)
  48. ... 35 more
  49. 十一月 01, 2016 7:55:49 下午 org.apache.catalina.core.StandardContext listenerStart
  50. 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
  51. org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [E:\gold_work\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\gold_public\WEB-INF\classes\com\golddashi\base\thirdpay\rongbao\configure\RBService.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [E:\gold_work\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\gold_public\WEB-INF\classes\com\golddashi\base\thirdpay\rongbao\configure\RBService.class]; nested exception is java.lang.IllegalArgumentException
  52. at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:290)
  53. at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:242)
  54. at org.springframework.context.annotation.ComponentScanBeanDefinitionParser.parse(ComponentScanBeanDefinitionParser.java:84)
  55. at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73)
  56. at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438)
  57. at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428)
  58. at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:185)
  59. at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139)
  60. at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108)
  61. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493)
  62. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390)
  63. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
  64. at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
  65. at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174)
  66. at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209)
  67. at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180)
  68. at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125)
  69. at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94)
  70. at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
  71. at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537)
  72. at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451)
  73. at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389)
  74. at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294)
  75. at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112)
  76. at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4994)
  77. at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5492)
  78. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
  79. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
  80. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
  81. at java.util.concurrent.FutureTask.run(Unknown Source)
  82. at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  83. at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  84. at java.lang.Thread.run(Unknown Source)
  85. Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [E:\gold_work\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\gold_public\WEB-INF\classes\com\golddashi\base\thirdpay\rongbao\configure\RBService.class]; nested exception is java.lang.IllegalArgumentException
  86. at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:56)
  87. at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80)
  88. at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102)
  89. at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:266)
  90. ... 32 more
  91. Caused by: java.lang.IllegalArgumentException
  92. at org.springframework.asm.ClassReader.<init>(Unknown Source)
  93. at org.springframework.asm.ClassReader.<init>(Unknown Source)
  94. at org.springframework.asm.ClassReader.<init>(Unknown Source)
  95. at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:53)
  96. ... 35 more
  97. 十一月 01, 2016 7:55:49 下午 org.apache.catalina.core.StandardContext startInternal
  98. 严重: Error listenerStart
  99. 十一月 01, 2016 7:55:49 下午 org.apache.catalina.core.StandardContext startInternal
  100. 严重: Context [/gold_public] startup failed due to previous errors
  101. 十一月 01, 2016 7:55:49 下午 org.apache.catalina.core.ApplicationContext log
  102. 信息: Closing Spring root WebApplicationContext
  103. - Closing Root WebApplicationContext: startup date [Tue Nov 01 19:55:49 GMT+08:00 2016]; root of context hierarchy
  104. - Exception thrown from ApplicationListener handling ContextClosedEvent
  105. java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Tue Nov 01 19:55:49 GMT+08:00 2016]; root of context hierarchy
  106. at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:347)
  107. at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:334)
  108. at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1049)
  109. at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
  110. at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
  111. at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
  112. at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5035)
  113. at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5687)
  114. at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
  115. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
  116. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
  117. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
  118. at java.util.concurrent.FutureTask.run(Unknown Source)
  119. at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  120. at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  121. at java.lang.Thread.run(Unknown Source)
  122. - Exception thrown from LifecycleProcessor on context close
  123. java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: Root WebApplicationContext: startup date [Tue Nov 01 19:55:49 GMT+08:00 2016]; root of context hierarchy
  124. at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:360)
  125. at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1057)
  126. at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
  127. at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
  128. at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
  129. at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5035)
  130. at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5687)
  131. at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
  132. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
  133. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
  134. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
  135. at java.util.concurrent.FutureTask.run(Unknown Source)
  136. at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  137. at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  138. at java.lang.Thread.run(Unknown Source)
  139. 十一月 01, 2016 7:55:49 下午 org.apache.catalina.core.StandardContext listenerStop
  140. 严重: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
  141. java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
  142. at org.springframework.context.support.AbstractRefreshableApplicationContext.getBeanFactory(AbstractRefreshableApplicationContext.java:171)
  143. at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1090)
  144. at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1064)
  145. at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:1010)
  146. at org.springframework.web.context.ContextLoader.closeWebApplicationContext(ContextLoader.java:559)
  147. at org.springframework.web.context.ContextLoaderListener.contextDestroyed(ContextLoaderListener.java:143)
  148. at org.apache.catalina.core.StandardContext.listenerStop(StandardContext.java:5035)
  149. at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5687)
  150. at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:232)
  151. at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:160)
  152. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
  153. at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
  154. at java.util.concurrent.FutureTask.run(Unknown Source)
  155. at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
  156. at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
  157. at java.lang.Thread.run(Unknown Source)

将spring从3.1升级到3.2启动tomcat出现如上错误,

仔细检查过web.xml中关于spring配置引入,spring-mvc配置引入都没有问题,

以及spring配置文件读取方式,包括监听参数配置也是对的,

关于引入和监听web.xml配置如下:

  1. <context-param>
  2. <param-name>contextConfigLocation</param-name>
  3. <param-value>
  4. classpath:spring/applicationContext-spring-rmi-client.xml,
  5. classpath:spring/spring-context.xml
  6. </param-value>
  7. </context-param>
  8. <listener>
  9. <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  10. </listener>
  11. <listener>
  12. <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
  13. </listener>

换回成3.1又没有问题,换成3.2又不行,查看编译环境用的是1.8,将1.8降为1.7,问题解决,服务启动正常,

也就是说spring 3.2不支持1.8编译环境,解决办法就是降为1.7编译环境

关于编译环境配置如图:

Center

spring官网说了,要使用java8,只支持spring 4.X以上版本,而spring的使用最低java要求java5及以上,

如果出现例外,那就例外说了,比如一开始spring 3.1就可以在java8上编译。

发表评论

表情:
评论列表 (有 0 条评论,271人围观)

还没有评论,来说两句吧...

相关阅读