java.lang.NullPointerException

There are no available Samebug tips for this exception. Do you have an idea how to solve this issue? A short tip would help users who saw this issue last week.

  • Using an ItemOrientedStep with the following combination of ItemReader and ItemWriter ... <!-- other tags --> <bean id="testFileItemReader" class="org.springframework.batch.item.xml.StaxEventItemReader"> <property name="fragmentRootElementName" value="record" /> <property name="resource" value="classpath:doesntexist.xml" /> <property name="fragmentDeserializer"> <bean class="org.springframework.batch.item.xml.oxm.UnmarshallingEventReaderDeserializer"> <constructor-arg ref="jaxb2Marshaller" /> </bean> </property> </bean> <bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> <property name="contextPath" value="${context.path}" /> <property name="schema" value="classpath:${input.schema}" /> </bean> <bean class="org.springframework.batch.item.xml.StaxEventItemWriter" id="testFileItemWriter"> <property name="resource" value="file:${output.resource}" /> <property name="serializer" ref="marshallingSerializer" /> <property name="rootTagName" value="records" /> <property name="overwriteOutput" value="true" /> </bean> <bean class="org.springframework.batch.item.xml.oxm.MarshallingEventWriterSerializer" id="marshallingSerializer"> <constructor-arg ref="jaxb2Marshaller" /> </bean> will lead to a NullPointerException in the execution of the ItemWriter if the resource configured for the ItemReader doesn't exist (for example due to an unintentional typo). This behavior makes it rather difficult to analyze the error and find the true cause. There should be a more sophisticated error handling if the StaxEventItemReader can't find its resource. Log entry: ERROR AbstractStep - Encountered an error executing the step: class org.springframework.batch.core.UnexpectedJobExecutionException: Failed to initialize the step ERROR AbstractStep - Exception while closing step execution resources java.lang.NullPointerException at org.springframework.batch.item.xml.StaxEventItemWriter.flush(StaxEventItemWriter.java:463) at org.springframework.batch.item.xml.StaxEventItemWriter.close(StaxEventItemWriter.java:373) at org.springframework.batch.item.support.CompositeItemStream.close(CompositeItemStream.java:90) at org.springframework.batch.core.step.item.ItemOrientedStep.close(ItemOrientedStep.java:435) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:226) at org.springframework.batch.core.job.SimpleJob.execute(SimpleJob.java:100) at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:86) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49) at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:81) at com.tsystems.favbg.batch.job.TestJobTest.testLaunchJob(TestJobTest.java:83) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    via by Dino Marzi,
  • Using an ItemOrientedStep with the following combination of ItemReader and ItemWriter ... <!-- other tags --> <bean id="testFileItemReader" class="org.springframework.batch.item.xml.StaxEventItemReader"> <property name="fragmentRootElementName" value="record" /> <property name="resource" value="classpath:doesntexist.xml" /> <property name="fragmentDeserializer"> <bean class="org.springframework.batch.item.xml.oxm.UnmarshallingEventReaderDeserializer"> <constructor-arg ref="jaxb2Marshaller" /> </bean> </property> </bean> <bean id="jaxb2Marshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller"> <property name="contextPath" value="${context.path}" /> <property name="schema" value="classpath:${input.schema}" /> </bean> <bean class="org.springframework.batch.item.xml.StaxEventItemWriter" id="testFileItemWriter"> <property name="resource" value="file:${output.resource}" /> <property name="serializer" ref="marshallingSerializer" /> <property name="rootTagName" value="records" /> <property name="overwriteOutput" value="true" /> </bean> <bean class="org.springframework.batch.item.xml.oxm.MarshallingEventWriterSerializer" id="marshallingSerializer"> <constructor-arg ref="jaxb2Marshaller" /> </bean> will lead to a NullPointerException in the execution of the ItemWriter if the resource configured for the ItemReader doesn't exist (for example due to an unintentional typo). This behavior makes it rather difficult to analyze the error and find the true cause. There should be a more sophisticated error handling if the StaxEventItemReader can't find its resource. Log entry: ERROR AbstractStep - Encountered an error executing the step: class org.springframework.batch.core.UnexpectedJobExecutionException: Failed to initialize the step ERROR AbstractStep - Exception while closing step execution resources java.lang.NullPointerException at org.springframework.batch.item.xml.StaxEventItemWriter.flush(StaxEventItemWriter.java:463) at org.springframework.batch.item.xml.StaxEventItemWriter.close(StaxEventItemWriter.java:373) at org.springframework.batch.item.support.CompositeItemStream.close(CompositeItemStream.java:90) at org.springframework.batch.core.step.item.ItemOrientedStep.close(ItemOrientedStep.java:435) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:226) at org.springframework.batch.core.job.SimpleJob.execute(SimpleJob.java:100) at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:86) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49) at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:81) at com.tsystems.favbg.batch.job.TestJobTest.testLaunchJob(TestJobTest.java:83) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    via by Dino Marzi,
    • java.lang.NullPointerException at org.springframework.batch.item.xml.StaxEventItemWriter.flush(StaxEventItemWriter.java:463) at org.springframework.batch.item.xml.StaxEventItemWriter.close(StaxEventItemWriter.java:373) at org.springframework.batch.item.support.CompositeItemStream.close(CompositeItemStream.java:90) at org.springframework.batch.core.step.item.ItemOrientedStep.close(ItemOrientedStep.java:435) at org.springframework.batch.core.step.AbstractStep.execute(AbstractStep.java:226) at org.springframework.batch.core.job.SimpleJob.execute(SimpleJob.java:100) at org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:86) at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49) at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:81) at com.tsystems.favbg.batch.job.TestJobTest.testLaunchJob(TestJobTest.java:83) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:585) at junit.framework.TestCase.runTest(TestCase.java:164) at junit.framework.TestCase.runBare(TestCase.java:130) at org.springframework.test.ConditionalTestCase.runBare(ConditionalTestCase.java:76) at junit.framework.TestResult$1.protect(TestResult.java:106) at junit.framework.TestResult.runProtected(TestResult.java:124) at junit.framework.TestResult.run(TestResult.java:109) at junit.framework.TestCase.run(TestCase.java:120) at junit.framework.TestSuite.runTest(TestSuite.java:230) at junit.framework.TestSuite.run(TestSuite.java:225) at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
    No Bugmate found.