找不到用于自省工厂方法的 class 文件:java.util.concurrent.ThreadPoolExecutor.DiscardPolicy

Could not find class file for introspecting factory methods: java.util.concurrent.ThreadPoolExecutor.DiscardPolicy

任何人,请帮我短路。 在 Jboss 上部署我的 war 文件时,它显示以下错误。我坚持自己找出原因。

[o.s.c.annotation.ConfigurationClassUtils] : Could not find class file for introspecting factory methods: java.util.concurrent.ThreadPoolExecutor.DiscardPolicy java.io.FileNotFoundException: class path resource [java/util/concurrent/ThreadPoolExecutor/DiscardPolicy.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:158) ~[org.springframework.core-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.springframework.core.type.classreading.SimpleMetadataReader.(SimpleMetadataReader.java:45) ~[org.springframework.core-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:80) ~[org.springframework.core-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:101) ~[org.springframework.core-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:76) ~[org.springframework.core-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.springframework.context.annotation.ConfigurationClassUtils.checkConfigurationClassCandidate(ConfigurationClassUtils.java:69) ~[org.springframework.context-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:216) [org.springframework.context-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:178) [org.springframework.context-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:617) [org.springframework.context-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:446) [org.springframework.context-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:384) [org.springframework.web-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:283) [org.springframework.web-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:111) [org.springframework.web-3.1.0.RELEASE.jar!/:3.1.0.RELEASE] at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.4.8.Final-redhat-4.jar!/:7.4.8.Final-redhat-4] at org.apache.catalina.core.StandardContext.start(StandardContext.java:3777) [jbossweb-7.4.8.Final-redhat-4.jar!/:7.4.8.Final-redhat-4] at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:161) [jboss-as-web-7.4.0.Final-redhat-19.jar!/:7.4.0.Final-redhat-19] at org.jboss.as.web.deployment.WebDeploymentService.access[=14=]0(WebDeploymentService.java:59) [jboss-as-web-7.4.0.Final-redhat-19.jar!/:7.4.0.Final-redhat-19] at org.jboss.as.web.deployment.WebDeploymentService.run(WebDeploymentService.java:94) [jboss-as-web-7.4.0.Final-redhat-19.jar!/:7.4.0.Final-redhat-19] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_74] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [na:1.8.0_74] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_74] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_74] at java.lang.Thread.run(Thread.java:745) [na:1.8.0_74] at org.jboss.threads.JBossThread.run(JBossThread.java:122) [jboss-threads-2.1.1.Final-redhat-1.jar!/:2.1.1.Final-redhat-1]

我找到的解决方案

我配置的 spring bean 引用注入有问题。

之前

<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"> 
                    <property name="corePoolSize" value="100" /> 
                    <property name="maxPoolSize" value="50" /> 
                    <property name="queueCapacity" value="150" /> 
                    <property name="rejectedExecutionHandler" ref="discardPolicy" /> 
</bean> 
<bean id="discardPolicy" class="java.util.concurrent.ThreadPoolExecutor.DiscardPolicy"/>

已修改(已解决)

<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"> 
            <property name="corePoolSize" value="100" /> 
            <property name="maxPoolSize" value="50" /> 
            <property name="queueCapacity" value="150" /> 
            <property name="rejectedExecutionHandler"> 
                <bean class="java.util.concurrent.ThreadPoolExecutor.DiscardPolicy"/> 
            </property>
</bean> 

配置的 spring bean ref 注入问题。

<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"> 
            <property name="corePoolSize" value="100" /> 
            <property name="maxPoolSize" value="50" /> 
            <property name="queueCapacity" value="150" /> 
            <property name="rejectedExecutionHandler"> 
                <bean class="java.util.concurrent.ThreadPoolExecutor.DiscardPolicy"/> 
            </property>
</bean>