Spring批次IllegalArgumentException:' beanName'不能为空

时间:2015-09-18 08:12:18

标签: java spring spring-integration spring-batch resin

我尝试使用java 5在Resin 2.1上部署Spring批处理应用程序,但我无法弄清楚这个异常。

问题似乎与冲突的库有关,因为JobRepository始终为null tr​​ansaction-manager属性(即使我设置了这个属性,即使我给了transactionManager一个beanName)

我使用弹簧(3.2.3)弹簧批(2.1.0)弹簧集成(2.1.6)和弹簧批集成(1.2.0)。 我试图调试框架,但仍然不明白哪个是问题。

这是stackTrace

09:57:47.567 [tcpConnection-8080-0] ERROR o.s.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from relative location [jobs/jobLauncherConfiguration.xml]
Offending resource: class path resource [application-context.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [jobs/jobLauncherConfiguration.xml]; nested exception is java.lang.IllegalArgumentException: 'beanName' must not be empty
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:76) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:272) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseDefaultElement(DefaultBeanDefinitionDocumentReader.java:197) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:182) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:174) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:209) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:180) ~[na:3.2.3.RELEASE]
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:125) ~[na:3.2.3.RELEASE]
    at org.springframework.web.context.support.XmlWebApplicationContext.loadBeanDefinitions(XmlWebApplicationContext.java:94) ~[na:3.2.3.RELEASE]
    at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130) ~[na:3.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:537) ~[na:3.2.3.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:451) ~[na:3.2.3.RELEASE]
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:389) ~[na:3.2.3.RELEASE]
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:294) ~[na:3.2.3.RELEASE]
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:112) [na:3.2.3.RELEASE]
    at com.caucho.server.http.Application.init(Application.java:1845) [resin.jar:na]
    at com.caucho.server.http.VirtualHost.startApplication(VirtualHost.java:1207) [resin.jar:na]
    at com.caucho.server.http.VirtualHost.getInvocation(VirtualHost.java:1007) [resin.jar:na]
    at com.caucho.server.http.ServletServer.getInvocation(ServletServer.java:1253) [resin.jar:na]
    at com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:250) [resin.jar:na]
    at com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:170) [resin.jar:na]
    at com.caucho.server.TcpConnection.run(TcpConnection.java:139) [resin.jar:na]
    at java.lang.Thread.run(Thread.java:595) [na:1.5.0_15]
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from class path resource [jobs/jobLauncherConfiguration.xml]; nested exception is java.lang.IllegalArgumentException: 'beanName' must not be empty
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:412) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.importBeanDefinitionResource(DefaultBeanDefinitionDocumentReader.java:256) ~[na:3.2.3.RELEASE]
    ... 27 common frames omitted
Caused by: java.lang.IllegalArgumentException: 'beanName' must not be empty
    at org.springframework.util.Assert.hasText(Assert.java:162) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.config.RuntimeBeanReference.<init>(RuntimeBeanReference.java:58) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.config.RuntimeBeanReference.<init>(RuntimeBeanReference.java:46) ~[na:3.2.3.RELEASE]
    at org.springframework.batch.core.configuration.xml.JobRepositoryParser.doParse(JobRepositoryParser.java:65) ~[na:na]
    at org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser.parseInternal(AbstractSingleBeanDefinitionParser.java:85) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.AbstractBeanDefinitionParser.parse(AbstractBeanDefinitionParser.java:59) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.NamespaceHandlerSupport.parse(NamespaceHandlerSupport.java:73) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1438) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseCustomElement(BeanDefinitionParserDelegate.java:1428) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.parseBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:185) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.doRegisterBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:139) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.DefaultBeanDefinitionDocumentReader.registerBeanDefinitions(DefaultBeanDefinitionDocumentReader.java:108) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.registerBeanDefinitions(XmlBeanDefinitionReader.java:493) ~[na:3.2.3.RELEASE]
    at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:390) ~[na:3.2.3.RELEASE]
    ... 30 common frames omitted

作业存储库和事务管理器的配置

<batch:job-repository id="jobRepository"
                          data-source="dataSourceSRS" isolation-level-for-create="READ_COMMITTED"
                          />



    <bean id="transactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSourceSRS"/>
    </bean>

我还试图从pom中排除Spring批量集成(当然不使用它的功能),但仍然收到相同的异常。

这是带有上下文加载监听器的web.xml

<context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath:application-context.xml</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

有什么想法吗?

感谢所有

修改

这里是application-context.xml

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">

    <bean id="configurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <list>
                <value>classpath:/job-config.properties</value>
                <value>classpath:/dataSources.properties</value>
                <value>classpath:/queries.properties</value>
                <value>file:${resin.home}/properties/job-config.properties</value>
                <value>file:${resin.home}/properties/dataSources.properties</value>
                <value>file:${resin.home}/properties/jobScheduler.properties</value>
                <value>file:${resin.home}/properties/queries.properties</value>
            </list>
        </property>
        <property name="ignoreUnresolvablePlaceholders" value="true"/>
        <property name="ignoreResourceNotFound" value="true"/>
    </bean>

    <context:component-scan base-package="com.mybatch.integration"/>

    <import resource="jobs/jobLauncherConfiguration.xml"/>

</beans>

和jobLauncherConfiguration.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:int="http://www.springframework.org/schema/integration"
       xmlns:int-http="http://www.springframework.org/schema/integration/http"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:batch="http://www.springframework.org/schema/batch"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
                           http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.1.xsd
                           http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http-2.1.xsd
                           http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">



    <batch:job-repository id="jobRepository"
                          data-source="dataSourceSRS" isolation-level-for-create="READ_COMMITTED"
                          />



    <bean id="transactionManager"
          class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSourceSRS"/>
    </bean>



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

    <int-http:inbound-gateway id="inboundGateway" request-channel="httpGetChannel" reply-channel="responseChannel"
                              supported-methods="GET" path="/loadFromRDB"/>

    <int:channel id="responseChannel"/>


    <int:service-activator id="activator" input-channel="httpGetChannel" method="startJob"
                           ref="jobLauncherController" output-channel="responseChannel"/>

    <bean id="srsSomJobRegistry" class="org.springframework.batch.core.configuration.support.MapJobRegistry"/>

    <bean id="srsSomJobExplorer" class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean">
        <property name="dataSource" ref="dataSourceSRS" />
    </bean>

    <bean id="srsSomJobOperator" class="org.springframework.batch.core.launch.support.SimpleJobOperator">
        <property name="jobExplorer" ref="srsSomJobExplorer"/>
        <property name="jobRepository" ref="jobRepository" />
        <property name="jobRegistry" ref="srsSomJobRegistry" />
        <property name="jobLauncher" ref="jobLauncher" />
    </bean>


    <import resource="configurations/dataSources.xml"/>

    <import resource="jobsConfigurations/srsSomJobManager.xml"/>


</beans>

0 个答案:

没有答案