Announcement Announcement Module
Collapse
No announcement yet.
After including the DB Repository, job is not starting Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • After including the DB Repository, job is not starting

    After replacing the Memory Job repository with the DB Job repository Job did not start.

    Here is the DB repository

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns="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.0.xsd">

    <bean id="jobRepository-dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
    <property name="url" value="jdbc:oracle:thin:@10.27.125.167:1521:w080d" />
    <property name="username" value="pcard" />
    <property name="password" value="butler12" />
    </bean>

    <bean id="jobRepository-transactionManager" class="org.springframework.jdbc.datasource.DataSou rceTransactionManager" lazy-init="true">
    <property name="dataSource" ref="jobRepository-dataSource" />
    </bean>

    <bean id="jobRepository" class="org.springframework.batch.core.repository.s upport.JobRepositoryFactoryBean">
    <property name="dataSource" ref="jobRepository-dataSource" />
    <property name="transactionManager" ref="jobRepository-transactionManager"/>
    <property name="databaseType" value="oracle" />
    <property name="tablePrefix" value="batch_"/>
    </bean>

    <bean id="asyncTaskExecutor" class="org.springframework.core.task.SimpleAsyncTa skExecutor"/>

    <bean id="syncTaskExecutor" class="org.springframework.core.task.SyncTaskExecu tor" />

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

    <bean id="jobExplorer" class="org.springframework.batch.core.explore.supp ort.JobExplorerFactoryBean" p:dataSource-ref="jobRepository-dataSource" p:tablePrefix="BATCH_" />

    </beans>

    Here is the last few lines of the log

    2011-03-18 15:55:57,352 [main] DEBUG - Invoking afterPropertiesSet() on bean with name 'jobRepository-transactionManager'
    2011-03-18 15:55:57,352 [main] DEBUG - Finished creating instance of bean 'jobRepository-transactionManager'
    2011-03-18 15:55:57,352 [main] DEBUG - Invoking afterPropertiesSet() on bean with name 'jobRepository'
    2011-03-18 15:55:57,446 [main] DEBUG - Adding transactional method[*] with attribute [PROPAGATION_REQUIRED,ISOLATION_DEFAULT]
    2011-03-18 15:55:57,446 [main] DEBUG - Adding transactional method [create*] with attribute [PROPAGATION_REQUIRES_NEW,ISOLATION_SERIALIZABLE]
    2011-03-18 15:55:57,446 [main] DEBUG - Adding transactional method [getLastJobExecution*] with attribute [PROPAGATION_REQUIRES_NEW,ISOLATION_SERIALIZABLE]
    2011-03-18 15:55:57,571 [main] DEBUG - Retrieved dependent beans for bean 'jobRepository-dataSource': [jobRepository-transactionManager]
    2011-03-18 15:55:57,571 [main] DEBUG - Invoking destroy method 'close' on bean with name 'jobRepository-dataSource'

  • #2
    again, please use [ CODE ] [ /CODE ] tags :-)

    I can't really see where the problem is, but it looks like from the logs that application context is just starting and then closing. Are you sure you're trying to launch anything?

    a couple of remarks to try to narrow down the problem:
    - use the batch namespace (for configuring the job repository for example)
    - remove the task executors definitions (they don't seem to do anything, at least in this file.)

    and BTW, you shouldn't expose the username/password to access your database on a public forum.

    Comment


    • #3
      Thanks Arno for the immediate reply.

      Regarding ur comment on batch namespace. Do u mean Batch Job name and the class name should be same.

      For example , XML Job file name and the Class name. Please confirm

      Comment


      • #4
        I meant <batch:job-repository /> instead of the usual <bean /> syntax. You can also remove lazy-init=true on the transaction manager, it doesn't take long to create a transaction manager bean and it makes your configuration more complex and harder to debug.

        Comment


        • #5
          I added the namespace but still I could not able to run the job. here is the config.

          Code:
           
          <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
          		xmlns:batch="http://www.springframework.org/schema/batch"
          		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.0.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">
          
          <!-- <import resource="MEMORY-JOBREPOSITORY.xml" /> -->
          
          <import resource="DB-JOBREPOSITORY.xml" />
          
            <bean id="emailBroadcast" class="com.wellsfargo.ccer.batch.broadcast.BroadCastEmail" scope="step">
              	<property name="message" value="Sent111111111111111111111111111111111"/>
              	<property name="status" value="#{jobParameters['status']}"/>
              </bean>
              
              <batch:job id="emailBroadcastjob" job-repository="jobRepository" restartable="true">
              	<batch:step id="step0" >
              		<batch:tasklet ref="emailBroadcast" transaction-manager="jobRepository-transactionManager">
                      </batch:tasklet>				
              	</batch:step>
              </batch:job>
          
             <bean id="jobLauncher"
          		class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
          		<property name="jobRepository" ref="jobRepository" />
          	</bean>
          	
          	<batch:job-repository id="jobRepository" />
          </beans>
          Here is the DB repository config

          Code:
          <?xml version="1.0" encoding="UTF-8"?>
          <beans xmlns="http://www.springframework.org/schema/beans"
          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.0.xsd">  
          
          <bean id="jobRepository-dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
          	<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />                	
          	<property name="url" value="jdbc:oracle:thin:@xxxxxxxxxxxx:1521:xxxx" />                	
          	<property name="username" value="xxxx" />        	
          	<property name="password" value="xxxxxx" /> 
          </bean>  
          
          <bean id="jobRepository-transactionManager"  class="org.springframework.jdbc.datasource.DataSourceTransactionManager" >
          	<property name="dataSource"  ref="jobRepository-dataSource" />   
          </bean> 
          
          
          
          <!-- <bean id="jobRepository" class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
             	<property name="dataSource" ref="jobRepository-dataSource" />   
          	<property name="transactionManager" ref="jobRepository-transactionManager"/>  
          	<property name="databaseType" value="oracle" />  
          	<property name="tablePrefix" value="batch_"/>
          	
          </bean> -->
          
          <bean id="jobLauncher" 
          	class="org.springframework.batch.core.launch.support.SimpleJobLauncher" >  	
          		<property name="jobRepository" ref="jobRepository"/>
          		<property name="taskExecutor">
          			<bean class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
          		</property>
          				
          	</bean>
          
          
          </beans>
          Last edited by Thil; Mar 25th, 2011, 05:30 PM. Reason: masked the IP and user credentials

          Comment


          • #6
            Continued

            Here is the log

            Code:
            2011-03-25 15:21:35,733 [main] DEBUG - Loaded 10 bean definitions from location pattern [broadCastEmailBatchJob.xml]
            2011-03-25 15:21:35,733 [main] DEBUG - 10 beans defined in org.springframework.context.support.ClassPathXmlApplicationContext@1d009b4: display name [org.springframework.context.support.ClassPathXmlApplicationContext@1d009b4]; startup date [Fri Mar 25 15:21:35 PDT 2011]; root of context hierarchy
            2011-03-25 15:21:35,748 [main] DEBUG - Creating shared instance of singleton bean 'org.springframework.batch.core.scope.internalStepScope'
            2011-03-25 15:21:35,764 [main] DEBUG - Creating instance of bean 'org.springframework.batch.core.scope.internalStepScope'
            2011-03-25 15:21:35,780 [main] DEBUG - Eagerly caching bean 'org.springframework.batch.core.scope.internalStepScope' to allow for resolving potential circular references
            2011-03-25 15:21:35,780 [main] DEBUG - Finished creating instance of bean 'org.springframework.batch.core.scope.internalStepScope'
            2011-03-25 15:21:35,780 [main] DEBUG - Creating shared instance of singleton bean 'org.springframework.beans.factory.config.CustomEditorConfigurer'
            2011-03-25 15:21:35,780 [main] DEBUG - Creating instance of bean 'org.springframework.beans.factory.config.CustomEditorConfigurer'
            2011-03-25 15:21:35,780 [main] DEBUG - Eagerly caching bean 'org.springframework.beans.factory.config.CustomEditorConfigurer' to allow for resolving potential circular references
            2011-03-25 15:21:35,795 [main] DEBUG - Finished creating instance of bean 'org.springframework.beans.factory.config.CustomEditorConfigurer'
            2011-03-25 15:21:35,811 [main] DEBUG - Creating shared instance of singleton bean 'org.springframework.batch.core.configuration.xml.CoreNamespacePostProcessor'
            2011-03-25 15:21:35,811 [main] DEBUG - Creating instance of bean 'org.springframework.batch.core.configuration.xml.CoreNamespacePostProcessor'
            2011-03-25 15:21:35,811 [main] DEBUG - Eagerly caching bean 'org.springframework.batch.core.configuration.xml.CoreNamespacePostProcessor' to allow for resolving potential circular references
            2011-03-25 15:21:35,811 [main] DEBUG - Finished creating instance of bean 'org.springframework.batch.core.configuration.xml.CoreNamespacePostProcessor'
            2011-03-25 15:21:35,811 [main] DEBUG - Returning cached instance of singleton bean 'org.springframework.batch.core.configuration.xml.CoreNamespacePostProcessor'
            2011-03-25 15:21:35,827 [main] DEBUG - Unable to locate MessageSource with name 'messageSource': using default [org.springframework.context.support.DelegatingMessageSource@facf0b]
            2011-03-25 15:21:35,827 [main] DEBUG - Unable to locate ApplicationEventMulticaster with name 'applicationEventMulticaster': using default [org.springframework.context.event.SimpleApplicationEventMulticaster@134b07e]
            2011-03-25 15:21:35,827 [main] DEBUG - Creating shared instance of singleton bean 'jobRepository-dataSource'
            2011-03-25 15:21:35,827 [main] DEBUG - Creating instance of bean 'jobRepository-dataSource'
            2011-03-25 15:21:35,827 [main] DEBUG - Eagerly caching bean 'jobRepository-dataSource' to allow for resolving potential circular references
            2011-03-25 15:21:35,842 [main] DEBUG - Finished creating instance of bean 'jobRepository-dataSource'
            2011-03-25 15:21:35,842 [main] DEBUG - Creating shared instance of singleton bean 'jobRepository-transactionManager'
            2011-03-25 15:21:35,842 [main] DEBUG - Creating instance of bean 'jobRepository-transactionManager'
            2011-03-25 15:21:35,842 [main] DEBUG - Eagerly caching bean 'jobRepository-transactionManager' to allow for resolving potential circular references
            2011-03-25 15:21:35,842 [main] DEBUG - Returning cached instance of singleton bean 'jobRepository-dataSource'
            2011-03-25 15:21:35,842 [main] DEBUG - Invoking afterPropertiesSet() on bean with name 'jobRepository-transactionManager'
            2011-03-25 15:21:35,842 [main] DEBUG - Finished creating instance of bean 'jobRepository-transactionManager'
            2011-03-25 15:21:35,842 [main] DEBUG - Creating shared instance of singleton bean 'jobLauncher'
            2011-03-25 15:21:35,842 [main] DEBUG - Creating instance of bean 'jobLauncher'
            2011-03-25 15:21:35,858 [main] DEBUG - Eagerly caching bean 'jobLauncher' to allow for resolving potential circular references
            2011-03-25 15:21:35,858 [main] DEBUG - Creating shared instance of singleton bean 'jobRepository'
            2011-03-25 15:21:35,858 [main] DEBUG - Creating instance of bean 'jobRepository'
            2011-03-25 15:21:35,873 [main] DEBUG - Eagerly caching bean 'jobRepository' to allow for resolving potential circular references

            Comment


            • #7
              Thil, on your place I would simply take a debugger and debug into a few level to see the problem. Maybe trivially the exception is thrown, which is swallowed and does not reach to logs.

              Comment


              • #8
                thanks dma for the reply.

                I configured the log4j.xml to have max as Error and could see the XML exception. After including streaming XML jar , job successfully ran and also it save the DB info in the tables.

                Thank you all for the excellent cooperation.

                Comment

                Working...
                X