java.lang.NullPointerException

Spring JIRA | Alexander Berresch | 9 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    I have configured a ItemOrientedStep with an ItemSkipPolicyItemHandler. If I use a stateless Hibernate SessionFactory it works all fine, but when I ┬┤change to a stateful Hibernate SessionFactory it throws an NullPointerException because mark() was called before open(), here is the Stacktrace: INFO: Job: [SimpleJob: [name=buLiStatisticJob2]] failed with the following parameters: [{}{}{}{}] java.lang.NullPointerException at org.springframework.batch.item.database.HibernateCursorItemReader.mark(HibernateCursorItemReader.java:185) at org.springframework.batch.core.step.item.SimpleItemHandler.mark(SimpleItemHandler.java:108) at org.springframework.batch.core.step.item.ItemSkipPolicyItemHandler.mark(ItemSkipPolicyItemHandler.java:223) at org.springframework.batch.core.step.item.ItemOrientedStep.execute(ItemOrientedStep.java:267) at org.springframework.batch.core.job.SimpleJob.execute(SimpleJob.java:125) 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 org.kingdeloui.batch.BuLiStatisticJob.testLaunchJob(BuLiStatisticJob.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:163) at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233) at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333) at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217) at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197) at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:142) at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51) at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44) at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27) at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37) at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) 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)

    Spring JIRA | 9 years ago | Alexander Berresch
    java.lang.NullPointerException
  2. 0

    I have configured a ItemOrientedStep with an ItemSkipPolicyItemHandler. If I use a stateless Hibernate SessionFactory it works all fine, but when I ┬┤change to a stateful Hibernate SessionFactory it throws an NullPointerException because mark() was called before open(), here is the Stacktrace: INFO: Job: [SimpleJob: [name=buLiStatisticJob2]] failed with the following parameters: [{}{}{}{}] java.lang.NullPointerException at org.springframework.batch.item.database.HibernateCursorItemReader.mark(HibernateCursorItemReader.java:185) at org.springframework.batch.core.step.item.SimpleItemHandler.mark(SimpleItemHandler.java:108) at org.springframework.batch.core.step.item.ItemSkipPolicyItemHandler.mark(ItemSkipPolicyItemHandler.java:223) at org.springframework.batch.core.step.item.ItemOrientedStep.execute(ItemOrientedStep.java:267) at org.springframework.batch.core.job.SimpleJob.execute(SimpleJob.java:125) 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 org.kingdeloui.batch.BuLiStatisticJob.testLaunchJob(BuLiStatisticJob.java:31) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:163) at org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233) at org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333) at org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217) at org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197) at org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:142) at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51) at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44) at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27) at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37) at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38) 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)

    Spring JIRA | 9 years ago | Alexander Berresch
    java.lang.NullPointerException

    Root Cause Analysis

    1. java.lang.NullPointerException

      No message provided

      at org.springframework.batch.item.database.HibernateCursorItemReader.mark()
    2. Spring Batch Infrastructure
      HibernateCursorItemReader.mark
      1. org.springframework.batch.item.database.HibernateCursorItemReader.mark(HibernateCursorItemReader.java:185)
      1 frame
    3. Spring Batch Core
      SimpleJobLauncher$1.run
      1. org.springframework.batch.core.step.item.SimpleItemHandler.mark(SimpleItemHandler.java:108)
      2. org.springframework.batch.core.step.item.ItemSkipPolicyItemHandler.mark(ItemSkipPolicyItemHandler.java:223)
      3. org.springframework.batch.core.step.item.ItemOrientedStep.execute(ItemOrientedStep.java:267)
      4. org.springframework.batch.core.job.SimpleJob.execute(SimpleJob.java:125)
      5. org.springframework.batch.core.launch.support.SimpleJobLauncher$1.run(SimpleJobLauncher.java:86)
      5 frames
    4. Spring Core
      SyncTaskExecutor.execute
      1. org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:49)
      1 frame
    5. Spring Batch Core
      SimpleJobLauncher.run
      1. org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:81)
      1 frame
    6. org.kingdeloui.batch
      BuLiStatisticJob.testLaunchJob
      1. org.kingdeloui.batch.BuLiStatisticJob.testLaunchJob(BuLiStatisticJob.java:31)
      1 frame
    7. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      4. java.lang.reflect.Method.invoke(Unknown Source)
      4 frames
    8. Spring TestContext
      SpringJUnit4ClassRunner.invokeTestMethod
      1. org.springframework.test.context.junit4.SpringTestMethod.invoke(SpringTestMethod.java:163)
      2. org.springframework.test.context.junit4.SpringMethodRoadie.runTestMethod(SpringMethodRoadie.java:233)
      3. org.springframework.test.context.junit4.SpringMethodRoadie$RunBeforesThenTestThenAfters.run(SpringMethodRoadie.java:333)
      4. org.springframework.test.context.junit4.SpringMethodRoadie.runWithRepetitions(SpringMethodRoadie.java:217)
      5. org.springframework.test.context.junit4.SpringMethodRoadie.runTest(SpringMethodRoadie.java:197)
      6. org.springframework.test.context.junit4.SpringMethodRoadie.run(SpringMethodRoadie.java:143)
      7. org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:142)
      7 frames
    9. JUnit
      JUnit4ClassRunner.run
      1. org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
      2. org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
      3. org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
      4. org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
      5. org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
      5 frames
    10. JUnit4 Runner
      JUnit4TestReference.run
      1. org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
      1 frame
    11. JUnit3 Runner
      RemoteTestRunner.main
      1. org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
      2. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
      3. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
      4. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
      5. org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
      5 frames