其他分享
首页 > 其他分享> > Only one AsyncAnnotationBeanPostProcessor may exist within the context 问题排查

Only one AsyncAnnotationBeanPostProcessor may exist within the context 问题排查

作者:互联网

启动tomcat时catalina.out中的错误日志:

1 22:14:29.161 [localhost-startStop-1] ERROR org.springframework.web.servlet.DispatcherServlet - Context initialization failed
2 org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Only one AsyncAnnotationBeanPostProcessor may exist within the context.
3 Offending resource: URL [jar:file:/usr/local/tomcat-xxx/lib/manage-nifi-group-1.0.0-SNAPSHOT.jar!/spring/controller/nifi-group.xml]
4         at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:70)
5         at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)
6         at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:72)
7         at org.springframework.scheduling.config.AnnotationDrivenBeanDefinitionParser.parse

定位到出问题的manage-nifi-group-1.0.0-SNAPSHOT.jar中的nifi-group.xml。

项目使用了spring定时器,上述配置文件中有 <task:annotation-driven scheduler=xxx />等定时器相关的配置。

百度错误原因,基本都集中在Spring的配置文件上,要么是<task:annotation-driven>标签重复,要么是文件头中如下内容重复:

<beans xmlns="http://www.springframework.org/schema/beans"
       .......
       xmlns:task="http://www.springframework.org/schema/task"
       xsi:schemaLocation=".........
                    http://www.springframework.org/schema/task
                    http://www.springframework.org/schema/task/spring-task-3.1.xsd
                    ">

 

在项目中仔细查验并未发现上述内容有重复配置的地方,于是继续翻看启动时的日志,发现在上面错误出现前,有以下内容:

1 22:43:55.319 [localhost-startStop-1] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Resolved classpath location [xxx/xxxx/xxxx/xxxx/xx/xxx/schedule/] to resources [URL [jar:file:/usr/local/tomcat-xxx/webapps/xxx/WEB-INF/lib/manage-nifi-group-1.0.0-SNAPSHOT.jar!/com/xxxx/xxxx/xxxx/xxxx/xxxx/schedule/], URL [jar:file:/usr/local/tomcat-xxxx/lib/manage-nifi-group-1.0.0-SNAPSHOT.jar!/com/xxxx/xxxx/xxxx/xxxx/idi/schedule/]]
2 22:43:55.319 [localhost-startStop-1] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in jar file [file:/usr/local/tomcat-xxx/webapps/manage-dataflow/WEB-INF/lib/manage-nifi-group-1.0.0-SNAPSHOT.jar]
3 22:43:55.320 [localhost-startStop-1] DEBUG org.springframework.core.io.support.PathMatchingResourcePatternResolver - Looking for matching resources in jar file [file:/usr/local/tomcat-xxx/lib/manage-nifi-group-1.0.0-SNAPSHOT.jar]

......

 

由此确定问题原因:同事误将manage-nifi-group-1.0.0-SNAPSHOT.jar上传到了tomcat的lib下,同时项目的lib下也有这个包,导致启动tomcat时这个包加载了两遍,Spring的task配置重复加载,从而出现该错误。

 

标签:nifi,xxxx,may,within,jar,springframework,Only,org,group
来源: https://www.cnblogs.com/enjoyable/p/16244505.html