Announcement Announcement Module
Collapse
No announcement yet.
Import the existing job file in new dependency bath job file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Import the existing job file in new dependency bath job file

    We have several Spring batch job files configured and tested . Batches are all working fine. Now I need to establish the dependencies among the batch jobs. So I am trying to reuse the existing batch files using the import statement I am getting the following is the Exception:

    Caused By: org.springframework.batch.core.configuration.Dupli cateJobException: A job configuration with this name [EmployeeEnrollmentComplete] was already registered
    at org.springframework.batch.core.configuration.suppo rt.MapJobRegistry.register(MapJobRegistry.java:56)
    at org.springframework.batch.core.configuration.suppo rt.DefaultJobLoader.doLoad(DefaultJobLoader.java:1 52)
    at org.springframework.batch.core.configuration.suppo rt.DefaultJobLoader.load(DefaultJobLoader.java:114 )
    at org.springframework.batch.core.configuration.suppo rt.AutomaticJobRegistrar.start(AutomaticJobRegistr ar.java:161)
    at org.springframework.batch.core.configuration.suppo rt.AutomaticJobRegistrar.onApplicationEvent(Automa ticJobRegistrar.java:128)
    Truncated. see log file for complete stacktrace
    >
    <Apr 16, 2013 11:25:02 AM EDT> <Error> <Deployer> <BEA-149202> <Encountered an exception while attempting to commit the 1 task for the application 'HBEBatchProcessWeb'.>
    <Apr 16, 2013 11:25:02 AM EDT> <Warning> <Deployer> <BEA-149004> <Failures were detected while initiating deploy task for application 'HBEBatchProcessWeb'.>
    <Apr 16, 2013 11:25:02 AM EDT> <Warning> <Deployer> <BEA-149078> <Stack trace for message 149004
    weblogic.application.ModuleException: :org.springframework.batch.core.configuration.Dupl icateJobException:A job configuration with this name [EmployeeEnrollmentComplete] was already registered
    at org.springframework.batch.core.configuration.suppo rt.MapJobRegistry.register(MapJobRegistry.java:56)
    at org.springframework.batch.core.configuration.suppo rt.DefaultJobLoader.doLoad(DefaultJobLoader.java:1 52)
    at org.springframework.batch.core.configuration.suppo rt.DefaultJobLoader.load(DefaultJobLoader.java:114 )
    at org.springframework.batch.core.configuration.suppo rt.AutomaticJobRegistrar.start(AutomaticJobRegistr ar.java:161)
    at org.springframework.batch.core.configuration.suppo rt.AutomaticJobRegistrar.onApplicationEvent(Automa ticJobRegistrar.java:128)
    Truncated. see log file for complete stacktrace
    >

    Simple Job Launcher using I am loading all job files at Start up;
    <bean
    class="org.springframework.batch.core.configuratio n.support.AutomaticJobRegistrar">
    <property name="applicationContextFactories">
    <bean
    class="org.springframework.batch.core.configuratio n.support.ClasspathXmlApplicationContextsFactoryBe an">
    <property name="resources" value="classpath:/jobs/*Job.xml" />
    </bean>
    </property>
    <property name="jobLoader">
    <bean
    class="org.springframework.batch.core.configuratio n.support.DefaultJobLoader">
    <property name="jobRegistry" ref="jobRegistry" />
    </bean>
    </property>
    </bean>

    New Dependency Config file:

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

    <import resource="EmployeeEnrollmentCompleteJob.xml" />
    <import resource="EmployeeAutoEnrollDuringEnrollmentJob.xm l" />


    <batch:job id="MainJob2" restartable="true">

    <batch:split id="MainJobSplit" task-executor="taskExecutor">

    <batch:flow>

    <batch:step id="EmployeeEnrollmentCompleteStep12">
    <batch:job ref="EmployeeEnrollmentComplete" job-launcher="jobLauncher"
    job-parameters-extractor="jobParametersExtractor" />
    </batch:step>

    </batch:flow>


    <batch:flow>
    <batch:step id="EmployeeAutoEnrollDuringEnrollmentStep12">
    <batch:job ref="EmployeeAutoEnrollDuringEnrollment" job-launcher="jobLauncher"
    job-parameters-extractor="jobParametersExtractor" />
    </batch:step>
    </batch:flow>

    </batch:split>


    </batch:job>

    <bean id="jobParametersExtractor" class="org.springframework.batch.core.step.job.Def aultJobParametersExtractor">
    <property name="keys" value="input.file"/>
    </bean>

    <bean id="taskExecutor" class="org.springframework.scheduling.concurrent.T hreadPoolTaskExecutor">
    <property value="8" name="corePoolSize" />
    <property value="8" name="maxPoolSize" />
    </bean>

    </beans>

    Definition of EmployeeEnrollmentCompleteJob.xml

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

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:batch="http://www.springframework.org/schema/batch" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd
    http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">

    <batch:job id="EmployeeEnrollmentComplete" restartable="true">
    <batch:step id="EmployeeEnrollmentCompleteJob">
    <batch:tasklet ref="EmployeeEnrollmentCompleteTasklet">
    <batch:no-rollback-exception-classes>
    <batch:include class="java.lang.Exception" />
    <batch:include class="com.hbe.wa.framework.exception.HBEServiceEx ception" />
    <batch:include class="javax.xml.ws.soap.SOAPFaultException" />
    </batch:no-rollback-exception-classes>
    </batch:tasklet>
    </batch:step>
    </batch:job>

    <bean id="EmployeeEnrollmentCompleteTasklet" class="com.hbe.wa.batch.shop.EmployeeEnrollmentCom plete"
    scope="step">
    <constructor-arg ref="employerService" />
    <constructor-arg value="#{jobParameters['As_of_A_Date']}"/>
    <property name="employerService" ref="employerService" />
    <property name="correspondenceService" ref="correspondenceService" />
    <property name="batchRecordExceptionsService" ref="batchRecordExceptionsService" />
    <property name="batchJobRequestService" ref="batchJobRequestService" />
    <property name="referenceDataService" ref="referenceDataService" />
    </bean>
    </beans>

  • #2
    As I wrote in my previous post we are loading the all the batch jobs with the name ending *job.xml into the memory map. And in my dependency job xml file as specified in the above post "<import resource="EmployeeEnrollmentCompleteJob.xml" />" it is also trying to load one more time causing the problem. I have changed the batch jobs name to "EmployeeEnrollmentComplete.xml" and imported the same with the new name. This has fixed the problem and nested batch job xml defined in the above also working fine.

    Comment

    Working...
    X