java.lang.NullPointerException: null

Spring JIRA | Raph C | 1 year ago
  1. 0

    Hi, I noticed Spring-batch causes a NullPointerException when I configure my context like this (@EnableBatchProcessing and BatchConfigurer) <pre><code> @EnableBatchProcessing public class ImpFidBatchConfiguration implements BatchConfigurer { .... } </code></pre> It seems that Spring register a default SimpleBatchConfiguration whereas I set mine by implementing BatchConfigurer. <pre> 2015-09-03 15:12:21.932 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registered bean definition for imported @Configuration class org.springframework.batch.core.configuration.annotation.ScopeConfiguration 2015-09-03 15:12:21.934 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.ScopeConfiguration.stepScope() 2015-09-03 15:12:21.934 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.ScopeConfiguration.jobScope() 2015-09-03 15:12:21.934 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registered bean definition for imported @Configuration class org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration 2015-09-03 15:12:21.934 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.jobRepository() 2015-09-03 15:12:21.934 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.jobLauncher() 2015-09-03 15:12:21.944 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.jobRegistry() 2015-09-03 15:12:21.944 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.jobExplorer() 2015-09-03 15:12:21.944 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.transactionManager() 2015-09-03 15:12:21.944 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.jobBuilders() 2015-09-03 15:12:21.944 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.stepBuilders() 2015-09-03 15:12:21.944 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registered bean definition for imported @Configuration class com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration 2015-09-03 15:12:21.954 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.prepare() 2015-09-03 15:12:21.954 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.extractArchive() 2015-09-03 15:12:21.954 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.stepScope() 2015-09-03 15:12:21.954 INFO [main] DefaultListableBeanFactory - Overriding bean definition for bean 'stepScope' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.ScopeConfiguration; factoryMethodName=stepScope; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/ScopeConfiguration.class]] with [Root bean: class [com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=stepScope; initMethodName=null; destroyMethodName=(inferred); defined in class com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration] 2015-09-03 15:12:21.954 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.jobScope() 2015-09-03 15:12:21.954 INFO [main] DefaultListableBeanFactory - Overriding bean definition for bean 'jobScope' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.ScopeConfiguration; factoryMethodName=jobScope; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/ScopeConfiguration.class]] with [Root bean: class [com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=jobScope; initMethodName=null; destroyMethodName=(inferred); defined in class com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration] 2015-09-03 15:12:21.954 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.repositoryFactoryBean() 2015-09-03 15:12:21.954 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.itemFailureLoggerListener() 2015-09-03 15:12:21.964 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.prepareTasklet() 2015-09-03 15:12:21.964 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.getJobExplorer() 2015-09-03 15:12:21.964 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.getJobLauncher() 2015-09-03 15:12:21.964 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.getJobRepository() 2015-09-03 15:12:21.964 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.getTransactionManager() </pre></code> BTW when I launch a job I get a NullPointerException because the JobRepository used to create the JobExecution instance (the default one) is not the same as this one injected in my flowJob instance (which is my own JobRepository). When the job try to update (AbstractJob.updateStatus) the JobExecution it fails :( <pre><code> 2015-09-03 15:12:22.911 ERROR [main] AbstractJob - Encountered fatal error executing job java.lang.NullPointerException: null at org.springframework.batch.core.repository.dao.MapJobExecutionDao.synchronizeStatus(MapJobExecutionDao.java:158) ~[spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE] at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:161) ~[spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_40] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_40] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_40] at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_40] </code></pre>

    Spring JIRA | 1 year ago | Raph C
    java.lang.NullPointerException: null
  2. 0

    Hi, I noticed Spring-batch causes a NullPointerException when I configure my context like this (@EnableBatchProcessing and BatchConfigurer) <pre><code> @EnableBatchProcessing public class ImpFidBatchConfiguration implements BatchConfigurer { .... } </code></pre> It seems that Spring register a default SimpleBatchConfiguration whereas I set mine by implementing BatchConfigurer. <pre> 2015-09-03 15:12:21.932 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registered bean definition for imported @Configuration class org.springframework.batch.core.configuration.annotation.ScopeConfiguration 2015-09-03 15:12:21.934 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.ScopeConfiguration.stepScope() 2015-09-03 15:12:21.934 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.ScopeConfiguration.jobScope() 2015-09-03 15:12:21.934 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registered bean definition for imported @Configuration class org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration 2015-09-03 15:12:21.934 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.jobRepository() 2015-09-03 15:12:21.934 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.jobLauncher() 2015-09-03 15:12:21.944 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.jobRegistry() 2015-09-03 15:12:21.944 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.jobExplorer() 2015-09-03 15:12:21.944 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.transactionManager() 2015-09-03 15:12:21.944 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.jobBuilders() 2015-09-03 15:12:21.944 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method org.springframework.batch.core.configuration.annotation.SimpleBatchConfiguration.stepBuilders() 2015-09-03 15:12:21.944 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registered bean definition for imported @Configuration class com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration 2015-09-03 15:12:21.954 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.prepare() 2015-09-03 15:12:21.954 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.extractArchive() 2015-09-03 15:12:21.954 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.stepScope() 2015-09-03 15:12:21.954 INFO [main] DefaultListableBeanFactory - Overriding bean definition for bean 'stepScope' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.ScopeConfiguration; factoryMethodName=stepScope; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/ScopeConfiguration.class]] with [Root bean: class [com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=stepScope; initMethodName=null; destroyMethodName=(inferred); defined in class com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration] 2015-09-03 15:12:21.954 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.jobScope() 2015-09-03 15:12:21.954 INFO [main] DefaultListableBeanFactory - Overriding bean definition for bean 'jobScope' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.batch.core.configuration.annotation.ScopeConfiguration; factoryMethodName=jobScope; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/batch/core/configuration/annotation/ScopeConfiguration.class]] with [Root bean: class [com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=jobScope; initMethodName=null; destroyMethodName=(inferred); defined in class com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration] 2015-09-03 15:12:21.954 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.repositoryFactoryBean() 2015-09-03 15:12:21.954 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.itemFailureLoggerListener() 2015-09-03 15:12:21.964 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.prepareTasklet() 2015-09-03 15:12:21.964 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.getJobExplorer() 2015-09-03 15:12:21.964 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.getJobLauncher() 2015-09-03 15:12:21.964 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.getJobRepository() 2015-09-03 15:12:21.964 DEBUG [main] ConfigurationClassBeanDefinitionReader - Registering bean definition for @Bean method com.bouygtel.inthd.batch.impfid.ImpFidBatchConfiguration.getTransactionManager() </pre></code> BTW when I launch a job I get a NullPointerException because the JobRepository used to create the JobExecution instance (the default one) is not the same as this one injected in my flowJob instance (which is my own JobRepository). When the job try to update (AbstractJob.updateStatus) the JobExecution it fails :( <pre><code> 2015-09-03 15:12:22.911 ERROR [main] AbstractJob - Encountered fatal error executing job java.lang.NullPointerException: null at org.springframework.batch.core.repository.dao.MapJobExecutionDao.synchronizeStatus(MapJobExecutionDao.java:158) ~[spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE] at org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:161) ~[spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.7.0_40] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[na:1.7.0_40] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.7.0_40] at java.lang.reflect.Method.invoke(Method.java:606) ~[na:1.7.0_40] </code></pre>

    Spring JIRA | 1 year ago | Raph C
    java.lang.NullPointerException: null
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

    2 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.NullPointerException

      null

      at org.springframework.batch.core.repository.dao.MapJobExecutionDao.synchronizeStatus()
    2. Spring Batch Core
      SimpleJobRepository.update
      1. org.springframework.batch.core.repository.dao.MapJobExecutionDao.synchronizeStatus(MapJobExecutionDao.java:158)[spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
      2. org.springframework.batch.core.repository.support.SimpleJobRepository.update(SimpleJobRepository.java:161)[spring-batch-core-3.0.2.RELEASE.jar:3.0.2.RELEASE]
      2 frames
    3. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)[na:1.7.0_40]
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)[na:1.7.0_40]
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)[na:1.7.0_40]
      4. java.lang.reflect.Method.invoke(Method.java:606)[na:1.7.0_40]
      4 frames