Announcement Announcement Module
Collapse
No announcement yet.
NoSuchJobException: No job configuration with the name Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • NoSuchJobException: No job configuration with the name

    Hi ..

    I'm having problem with starting my configured jobs using quartz 1.6.5 and Spring-Batch 2.0.1

    I gret error
    HTML Code:
    15:23:45,001 ERROR [BillingJobDetail] Could not execute job.
    org.springframework.batch.core.launch.NoSuchJobException: No job configuration with the name [billingCalculationsJob] was registered
    	at org.springframework.batch.core.configuration.support.MapJobRegistry.getJob(MapJobRegistry.java:79)
    	at si.kliping.billing.server.jobs.BillingJobDetail.executeInternal(BillingJobDetail.java:85)
    	at org.springframework.scheduling.quartz.QuartzJobBean.execute(QuartzJobBean.java:86)
    	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)

    spring batch configuration stuff ..
    PHP Code:
    <!-- spring batch  -->
        
        <
    bean id="jobRegistry" class="org.springframework.batch.core.configuration.support.MapJobRegistry" />
        
        <
    bean id="jobRepository"
            
    class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean"
            
    p:dataSource-ref="dataSourceBilling" p:transactionManager-ref="transactionManager"
        
    />
            
        
        <
    bean id="jobLauncher"
            
    class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
            <
    property name="jobRepository" ref="jobRepository" />
        </
    bean>

        <
    bean class="org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor">
            <
    property name="jobRegistry" ref="jobRegistry"/>
        </
    bean>
        
        <
    bean id="jobOperator" 
            
    class="org.springframework.batch.core.launch.support.SimpleJobOperator"
            
    p:jobLauncher-ref="jobLauncher"
            
    p:jobExplorer-ref="jobExplorer"
            
    p:jobRepository-ref="jobRepository"
            
    p:jobRegistry-ref="jobRegistry" />
        
        <
    bean id="jobExplorer"
            
    class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean"
            
    p:dataSource-ref="dataSourceBilling" />
        
        
        <
    bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
            <!--<
    property name="dataSource" ref="dataSourceBilling" />-->
            <
    property name="triggers">
                <
    bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
                    <
    property name="jobDetail" ref="jobDetail" />
                    <
    property name="cronExpression" value="0/15 * * * * ?" />
                </
    bean>
            </
    property>
        </
    bean>

        <
    bean id="jobDetail" class="org.springframework.scheduling.quartz.JobDetailBean" >
            <
    property name="jobClass" value="my.package.BillingJobDetail"  /> 
            <
    property name="group" value="quartz-batch" />
            <
    property name="jobDataAsMap">
                <
    map>
                    <
    entry key="jobName" value="billingCalculationsJob" />
                    <
    entry key="jobOperator"><ref bean="jobOperator"/></entry>
                    <
    entry key="jobLocator"><ref bean="jobRegistry"/></entry>
                    <
    entry key="jobLauncher"><ref bean="jobLauncher"/></entry>
                </
    map>
            </
    property>
        </
    bean

    my job definition
    PHP Code:
    <!-- JOBs definitions -->
        
        <
    job id="billingCalculationsJob" job-repository="jobRepository">
            <
    step id="prepareDocumentItems" next="invokeCalculations">
                <
    tasklet ref="tmpDocumentItemsPreparator" />
            </
    step>
            <
    step id="invokeCalculations" next="distributeCalculations">
                <
    tasklet ref="calculationProcessInvokator" />
            </
    step>
            <
    step id="distributeCalculations">
                <
    tasklet ref="calculationDistributer" />
            </
    step>
        </
    job
    can somone please take a look at this and tell me what I'm I doing wrong .. I can't figure it out

    kind regards

    Armando

  • #2
    after spending 2 days trying to figure it out ...

    my guess is that my job is not being registered on startup, since nothing is written in database on deployment ... I thing there was also a bug report on this matter in Jira and the problem is fixed in 2.0.2 .. although It will take till 28th of august to get the release.
    For now, can someone please direct me to some example, how to register my job in the code not with configuration file ?

    Kind regards

    Armando

    Comment


    • #3
      There is a workaround in the JIRA (http://jira.springframework.org/browse/BATCH-1282), but that only applies if you are using JobRegistryBeanPostProcessor, which you are not. You can also register your jobs manually in application code, and I guess that was what you intended to do but didn't, since the BeanPostProcessor is absent?

      Nice formatting on your XML.

      Comment


      • #4
        Hey man .. thank you for your reply

        I'm having JobRegistryBeanPostProcessor in my XML
        PHP Code:
        <bean class="org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor">
                <
        property name="jobRegistry" ref="jobRegistry"/>
            </
        bean
        I read about it and added it later in the process of learning / exploring ..

        btw .. I read about this workaround and got stuck with your comment

        HTML Code:
        N.B. workaround for 2.0.1 is simply to force all jobs to be instantiated (e.g. add them to a <util:list/>). 
        can you please provide some explanation or another link to where I can read about it ..

        Kind regrads

        Armando

        Comment


        • #5
          PHP Code:
          <util:list>
            <
          ref bean="billingCalculationsJob"/>
            <
          ref bean="job2"/>
            <
          ref bean="job3"/>
            ...
          </
          util:list> 

          Comment


          • #6
            tried that but receiving exeption
            HTML Code:
            org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/billing-jobs.xml]
            Offending resource: ServletContext resource [/WEB-INF/Billing-servlet.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 44 in XML document from class path resource [billing-jobs.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'ref'.
            billing-jobs.xml starts with ..
            PHP Code:
            <?xml version="1.0" encoding="UTF-8"?>
            <beans:beans xmlns="http://www.springframework.org/schema/batch"
                xmlns:beans="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:util="http://www.springframework.org/schema/util"
                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/batch http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
                    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
                    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
                    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd"
                
                >
            <!-- all jobs and step definitions ...-->
                <util:list>
                    <ref bean="billingCalculationsJob"/> 
                </util:list>
                
                
            </beans:beans>
            am I missing some namespace or some jar maybe ??

            trying to find me post about this on the forum ...

            Kind regards

            Armando

            Comment


            • #7
              Got it !

              since I'm using batch as primary namespace in jobs file, I should have written

              PHP Code:
              <util:list id="billingJobs">
                  <
              beans:ref bean="billingCalculationsJob"/> 
              </
              util:list> 

              Comment


              • #8
                I finaly got it working .. thank you ..

                my job gets registered and started on cron job ...

                Kind regards

                Armando

                Comment


                • #9
                  Problem persists in 2.0.2

                  I'm using Spring Batch 2.0.2 now, and this problem is still there. The workaround does the trick, thankfully.

                  Brian

                  Comment


                  • #10
                    How did you configure your Job? The fix went into 2.0.2, so if you have a similar experience it must be something esle, or you have 2.0.1 still on your classpath.

                    Comment


                    • #11
                      As requested: my job configuration

                      Dave,

                      Here is the configuration information for my job:

                      Code:
                      <batch:job id="myJob" job-repository="jobRepository">
                        <batch:step id="updateTrackingInProcess" next="myStep">
                          <batch:tasklet transaction-manager="transactionManager"
                            ref="updateTrackingInProcessTasklet" />
                        </batch:step>
                        <batch:step id="myStep" next="updateTrackingCompleted">
                          <batch:tasklet transaction-manager="transactionManager">
                            <batch:chunk reader="myReader" processor="myProcessor" 
                              writer="myWriter" commit-interval="100"/>
                          </batch:tasklet>
                        </batch:step>
                        <batch:step id="updateTrackingCompleted">
                          <batch:tasklet transaction-manager="transactionManager"
                            ref="updateTrackingCompletedTasklet" />
                        </batch:step>
                      </batch:job>
                      I can paste other elements here as needed, but the config entire is pretty big.

                      Brian

                      Comment


                      • #12
                        Nothing wrong with that. And you are using a JobRegistryBeanPostProcessor?

                        Comment


                        • #13
                          JobRegistryBeanPostProcessor included

                          Yes, here is the configuration for that. I also added my Job to a list so that it would be initialized as follows:

                          Code:
                          <util:list id="myJobs">
                            <ref bean="myJob"/>
                          </util:list>
                              
                          <bean id="jobRegistryBeanPostProcessor"
                            class="org.springframework.batch.core.configuration.support.JobRegistryBeanPostProcessor">
                            <property name="jobRegistry" ref="jobRegistry" />
                          </bean>
                          Is there something else that I should be doing for that?

                          Brian

                          Comment


                          • #14
                            The <util:list/> is not necessary in 2.0.2. Are you sure you got the right jars on your classpath? There is a test for this https://fisheye.springsource.org/bro...ext.xml?r=HEAD.

                            Comment


                            • #15
                              More details, and yes, I'm sure.

                              Dave,

                              I'll give you more detail on this, and perhaps that will help. First of all, I'm certain that I'm pointing at the right jars. This problem only appeared, however, when the Job was getting fired from a SchedulerFactoryBean via a CronTriggerBean. I think that changes how things are getting initialized.

                              Here is the config for those beans:

                              Code:
                              <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
                                <property name="triggers">
                                  <bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
                                    <property name="jobDetail" ref="jobDetail" />
                                    <property name="cronExpression" value="${spa.mw.cronexpression}" />
                                  </bean>
                                </property>
                                <property name="waitForJobsToCompleteOnShutdown" value="true" />
                              </bean>
                              
                              <bean id="jobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
                                <property name="jobClass" value="com...JobLauncherDetails" />
                                <property name="group" value="spa-batch" />
                                <property name="jobDataAsMap">
                                  <map>
                                    <entry key="jobName" value="myJob"/>
                                    <entry key="jobLocator" value-ref="jobRegistry"/>
                                    <entry key="jobLauncher" value-ref="jobLauncher"/>
                                    <entry key="fileWatcher" value-ref="myFileWatcher"/>
                                  </map>
                                </property>
                              </bean>
                              And here is the code from my version of the JobLauncherDetails.

                              Code:
                              protected void executeInternal(JobExecutionContext context) {
                                
                                JobParameters fileParameters = fileWatcher.run();
                                if (fileParameters != null) {
                                  Map<String, Object> jobDataMap = context.getMergedJobDataMap();
                                  String jobName = (String) jobDataMap.get(JOB_NAME);
                                  log.debug("Quartz trigger firing with Spring Batch jobName="+jobName);
                                  JobParameters jobParameters = getJobParametersFromJobMap(jobDataMap);
                                  jobParameters = mergeParameters(jobParameters, fileParameters);
                                  try {
                                    jobLauncher.run(jobLocator.getJob(jobName), jobParameters);
                                  } catch (  .. exception handling			}			
                                } else { 
                                  log.debug("File already processed");
                                }
                              }
                              Perhaps you can see something different here than what your test shows.

                              Brian

                              Comment

                              Working...
                              X