在Spring Batch中创建作业时出错 [英] Error creating Job in Spring Batch

查看:99
本文介绍了在Spring Batch中创建作业时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用JDeveloper和Weblogic 12c(12.1.3),并且想使用Spring Batch使用XML创建作业.当我部署项目时,它显示了我和错误.由于工作上的某些限制,我还需要使用此IDE,而且也无需使用maven.

I'm using JDeveloper and Weblogic 12c(12.1.3) and I want to create a job with XML using Spring Batch. When I deploy the project It shows me and error. I need to use this IDE because of some restrictions in my job, also, without using maven.

几个例子,我认为我的XML很好.我认为问题与weblogic (我有一个),因为我使用Netbeans IDE和GlassFish Open Source Edition 4.1.1对相同的项目结构和库进行了相同的测试,并且可以正常工作.

I've seen several example and I think my XML it's fine. I think the problem is related to weblogic (I had a similar issue) because I made the same test with the same project structure and libraries using Netbeans IDE and GlassFish Open Source Edition 4.1.1, and it works.

aopalliance-1.0.jar
com.ibm.jbatch-tck-spi-1.0.jar
commons-logging-1.1.3.jar
hsqldb-2.3.3.jar
javax.batch-api-1.0.jar
jettison-1.2.jar
spring-aop-4.0.5.RELEASE.jar
spring-batch-core-3.0.5.RELEASE.jar
spring-batch-infrastructure-3.0.5.RELEASE.jar
spring-beans-4.0.5.RELEASE.jar
spring-context-4.0.5.RELEASE.jar
spring-core-4.0.5.RELEASE.jar
spring-expression-4.0.5.RELEASE.jar
spring-jdbc-4.0.5.RELEASE.jar
spring-retry-1.1.0.RELEASE.jar
spring-tx-4.0.5.RELEASE.jar
spring-web-4.0.5.RELEASE.jar
spring-webmvc-4.0.5.RELEASE.jar
xmlpull-1.1.3.1.jar
xpp3_min-1.1.4c.jar
xstream-1.4.7.jar

错误

<org.springframework.web.servlet.FrameworkServlet> <FrameworkServlet> <initServletBean> <Context initialization failed> 
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jobLauncherController': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.batch.core.Job batch.JobLauncherController.job; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'job': Initialization of bean failed; nested exception is java.lang.reflect.MalformedParameterizedTypeException
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:429)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:728)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:380)
        at org.springframework.web.servlet.FrameworkServlet.createWebApplicationContext(FrameworkServlet.java:402)
        at org.springframework.web.servlet.FrameworkServlet.initWebApplicationContext(FrameworkServlet.java:316)
        at org.springframework.web.servlet.FrameworkServlet.initServletBean(FrameworkServlet.java:282)
        at org.springframework.web.servlet.HttpServletBean.init(HttpServletBean.java:126)
        at javax.servlet.GenericServlet.init(GenericServlet.java:240)

我的应用程序上下文XML是这样的:

My application context XML is this:

testBatch-servlet.xml

testBatch-servlet.xml

  <beans:beans xmlns="http://www.springframework.org/schema/batch"
                 xmlns:beans="http://www.springframework.org/schema/beans"
                 xmlns:context="http://www.springframework.org/schema/context"
                 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-3.0.xsd http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
        <context:component-scan base-package="batch"/>
        <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <beans:property name="prefix" value="/"/>
            <beans:property name="suffix" value=".jsp"/>
        </beans:bean>
        <beans:bean id="transactionManager"
                    class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"></beans:bean>
        <beans:bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <beans:property name="driverClassName" value="oracle.jdbc.OracleDriver"/>
            <beans:property name="url" value="jdbc:oracle:thin:@//localhost:1521/xe"/>
            <beans:property name="username" value="system"/>
            <beans:property name="password" value="1234"/>
        </beans:bean>
        <beans:bean id="jobRepository" class="org.springframework.batch.core.repository.support.SimpleJobRepository">
            <beans:constructor-arg>
                <beans:bean class="org.springframework.batch.core.repository.dao.MapJobInstanceDao"/>
            </beans:constructor-arg>
            <beans:constructor-arg>
                <beans:bean class="org.springframework.batch.core.repository.dao.MapJobExecutionDao"/>
            </beans:constructor-arg>
            <beans:constructor-arg>
                <beans:bean class="org.springframework.batch.core.repository.dao.MapStepExecutionDao"/>
            </beans:constructor-arg>
            <beans:constructor-arg>
                <beans:bean class="org.springframework.batch.core.repository.dao.MapExecutionContextDao"/>
            </beans:constructor-arg>
        </beans:bean>
        <beans:bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
            <beans:property name="jobRepository" ref="jobRepository"/>
            <beans:property name="taskExecutor">
                <beans:bean class="org.springframework.core.task.SimpleAsyncTaskExecutor"/>
            </beans:property>
        </beans:bean>
        <beans:bean id="myTasklet" class="batch.MyTasklet"></beans:bean>
        <job id="job" job-repository="jobRepository">
            <step id="test" >
                <tasklet ref="myTasklet"/>
            </step>
        </job>
    </beans:beans>

有什么想法吗?

推荐答案

我认为您必须使用Filtering Classloading,包括所需的Spring版本.

I think you must use Filtering Classloading including the version of Spring you need.

http://docs.oracle.com/cd/E12839_01/web.1111/e13706/classloading.htm

如果它是战争文件,则将true添加到weblogic.xml

If it is a war file then add true to weblogic.xml

WLS 12.1.3支持该版本:

That version is supported in WLS 12.1.3 :

WLS 12.1.3 Spring Framework 3.0.x,3.1.x和4.0.x版本(请注意,不支持3.2.x版本)(不支持并不意味着将无法使用).

WLS 12.1.3 Spring Framework versions 3.0.x, 3.1.x, and 4.0.x (note that version 3.2.x is not supported) (not-supported doesn't mean won't work).

这篇关于在Spring Batch中创建作业时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆