当前位置: 首页 > 知识库问答 >
问题:

无法解析对bean MapExecutionContext道的引用

董飞
2023-03-14

我是Spring的新手,在尝试将项目从Java6升级到Java8时遇到了此错误。

    00:51:42,543 ERROR main CommandLineJobRunner:355 - Job Terminated in error: Unexpected exception parsing XML document from class path resource [app-c
ontext/bprpp-context.xml]; nested exception is java.lang.IllegalStateException: Context namespace element 'annotation-config' and its parser class [o
rg.springframework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher
org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [app-context/bprpp
-context.xml]; nested exception is java.lang.IllegalStateException: Context namespace element 'annotation-config' and its parser class [org.springfra
mework.context.annotation.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:420)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:342)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:310)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
        at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
        at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:113)
        at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:80)
        at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:12
3)
        at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:422)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:352)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
        at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:282)
        at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:574)
Caused by: java.lang.IllegalStateException: Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotatio
n.AnnotationConfigBeanDefinitionParser] are only available on JDK 1.5 and higher
        at org.springframework.context.config.ContextNamespaceHandler$1.parse(ContextNamespaceHandler.java:65)
        at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:69)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1297)
        at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1287)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:13
5)
        at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java
:92)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:507)
        at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:398)
        ... 15 more
2018-09-20 00:51:42 - ***** step050 - java rc=1

我在这里读到,要解决这个问题,要么使用Java 7,要么升级Spring版本。Java 7不行,因为我的目标是升级到Java 8,所以我尝试将Spring版本从2.1.9升级到4.0.0,结果出现以下错误:

14:45:27,006 ERROR main CommandLineJobRunner:370 - Job Terminated in error: Error creating bean with name 'jobRepository' defined in class path resource [app-context/bprpp-memory-context.xml]: Cannot resolve reference to bean 'executionContextDao' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'executionContextDao' defined in class path resource [app-context/bprpp-memory-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.batch.core.repository.dao.MapExecutionContextDao]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/DecoratingProxy
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobRepository' defined in class path resource [app-context/bprpp-memory-context.xml]: Cannot resolve reference to bean 'executionContextDao' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'executionContextDao' defined in class path resource [app-context/bprpp-memory-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.batch.core.repository.dao.MapExecutionContextDao]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/DecoratingProxy
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:328)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:106)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveConstructorArguments(ConstructorResolver.java:616)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:148)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:585)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:913)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:464)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:292)
    at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:596)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'executionContextDao' defined in class path resource [app-context/bprpp-memory-context.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.batch.core.repository.dao.MapExecutionContextDao]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/DecoratingProxy
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:997)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:943)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
    at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:322)
    ... 18 more
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.batch.core.repository.dao.MapExecutionContextDao]: Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/DecoratingProxy
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:162)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:76)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:990)
    ... 26 more
Caused by: java.lang.NoClassDefFoundError: org/springframework/core/DecoratingProxy
    at org.springframework.aop.framework.AopProxyUtils.completeProxiedInterfaces(AopProxyUtils.java:135)
    at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:121)
    at org.springframework.aop.framework.JdkDynamicAopProxy.getProxy(JdkDynamicAopProxy.java:113)
    at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:97)
    at org.springframework.batch.support.transaction.TransactionAwareProxyFactory.createInstance(TransactionAwareProxyFactory.java:154)
    at org.springframework.batch.support.transaction.TransactionAwareProxyFactory.createAppendOnlyTransactionalMap(TransactionAwareProxyFactory.java:170)
    at org.springframework.batch.core.repository.dao.MapExecutionContextDao.<init>(MapExecutionContextDao.java:41)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:147)
    ... 28 more
Caused by: java.lang.ClassNotFoundException: org.springframework.core.DecoratingProxy
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 40 more

以下是相关文件:

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.xcel.brp</groupId>
    <artifactId>BRP-BATCH</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>BRP-BATCH</name>
    <!-- <url>http://maven.apache.org</url> -->

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <spring.version>3.1.1.RELEASE</spring.version>
        <!-- <junit.version>4.4</junit.version> -->
        <junit.version>4.12</junit.version>
        <snowdrop.version>2.0.0.Final</snowdrop.version>
        <commons-logging.version>1.1.1</commons-logging.version>
        <cxf.version>2.4.6</cxf.version>
        <slf4j.version>1.5.8</slf4j.version>
        <spp.version>1.0-SNAPSHOT</spp.version>
        <log4j.version>1.2.16</log4j.version>
        <!-- <spring-batch.version>2.1.9.RELEASE</spring-batch.version> -->
    </properties>


    <dependencies>
        <dependency>
            <groupId>org.springframework.batch</groupId>
            <artifactId>spring-batch-core</artifactId>
            <!-- <version>2.1.9.RELEASE</version> -->
            <version>4.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.batch</groupId>
            <artifactId>spring-batch-test</artifactId>
            <!-- <version>${spring-batch.version}</version> -->
            <version>4.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>1.5.10</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>${commons-logging.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${junit.version}</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-oxm-tiger</artifactId>
            <version>1.5.10</version>
        </dependency>

    </dependencies>
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.java</include>
                    <include>**/*.gwt.xml</include>
                </includes>
            </resource>
        </resources>
    </build>

</project>

bprpp-memory-context.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd 
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> 

    <bean id="jobRepository" 
          class="org.springframework.batch.core.repository.support.SimpleJobRepository">
        <constructor-arg index="0" ref="jobInstanceDao"      />
        <constructor-arg index="1" ref="jobExecutionDao"     />
        <constructor-arg index="2" ref="stepExecutionDao"    />
        <constructor-arg index="3" ref="executionContextDao" />
    </bean>
    <bean id="jobInstanceDao" 
          class="org.springframework.batch.core.repository.dao.MapJobInstanceDao" />

    <bean id="jobExecutionDao" 
          class="org.springframework.batch.core.repository.dao.MapJobExecutionDao" />

    <bean id="stepExecutionDao" 
          class="org.springframework.batch.core.repository.dao.MapStepExecutionDao" />

    <bean id="executionContextDao" 
          class="org.springframework.batch.core.repository.dao.MapExecutionContextDao" />

    <bean id="jobExplorer" 
          class="org.springframework.batch.core.explore.support.SimpleJobExplorer">
        <constructor-arg index="0" ref="jobInstanceDao"      />
        <constructor-arg index="1" ref="jobExecutionDao"     />
        <constructor-arg index="2" ref="stepExecutionDao"    />
        <constructor-arg index="3" ref="executionContextDao" />
    </bean>

    <bean id="jobLauncher" 
          class="org.springframework.batch.core.launch.support.SimpleJobLauncher" >     
        <property name="jobRepository" ref="jobRepository" />        
    </bean>

    <bean id="transactionManager" 
          class="org.springframework.batch.support.transaction.ResourcelessTransactionManager" /> 

</beans>

共有1个答案

松兴邦
2023-03-14

您的问题是使用maven BOM解决的典型问题。对于Spring项目,我建议使用Spring Boot BOM而不是手动导入依赖项和指定版本。此BOM将带来已知可以很好地协同工作的Spring依赖项。即使您不使用Spring Boot,您也可以使用此BOM。

在您的情况下,如果您使用Spring Boot版本2.0.5.RELEASE,它将带来Spring Batch 4.0.1.RELEASE以及Spring Framework 5.0.9.RELEASE。

希望这有帮助。

 类似资料:
  • 我尝试将我的应用程序配置为使用Spring数据 neo4j 。 但是当我提交我的应用程序时,我得到了这个堆栈跟踪跟踪: 这是我的UserRepository: 这是我的porm.xml http://maven.apache.org/maven-v4_0_0.xsd"

  • 在尝试部署集成了Spring Security性的jsf项目时,我遇到了以下错误。我今天才开始使用Spring Security性,因为安全领域的javaee安全性太麻烦了。我看了这个教程。所以我不确定这个错误到底意味着什么。我今天也开始了分级,所以我把依赖项包括在内,以防万一。 (我会将错误作为引号放在页面底部)。 应用程序上下文.xml 我的渐变依赖项: 我的web.xml 并promise为

  • 我正在学习OpenApi。我从Swagger那里得到了这个错误: TypeError: O是未定义的值parameter-row.jsx:149渲染root-injects.jsx:93React 8_renderValidatedComponentWithoutOwnerOrContext_renderValidatedComponent性能初始安装安装组件安装组件安装儿童_createInit

  • Iam使用spring、hibernate maven项目时出现异常,无法在dispatcher servlet上解析对bean“sessionFactory”的引用。xml文件。下面是iam添加的三个文件内容。dispatcherservlet和应用程序上下文都位于resources文件夹中。问题是什么?请帮忙 我的错误:org。springframework。网状物util。NestedSer

  • 目前,我在netty管道的末尾有一个处理程序,它处理几乎所有的请求逻辑。(使用jackson、身份验证、速率限制等从json解析对象。如果把这些放在执行器之后的管道中的各个阶段,是不是更好地使用管道结构?

  • 我刚刚迁移到spring JPA技术,并设法将我的简单jersey hibernate项目更改为具有自定义crudrepository的spring JPA。但我不能处理自动配置EntityManagerFactorybean。下面是我的代码: application.properties: 应用程序: 错误日志报告: LogHandler: 错误日志: pom。xml 最后是我的堆栈跟踪: 谢谢