Search code examples
spring-batchjava-6

Spring batch 3.0.2 dependency with javax.batch.runtime.JobInstance


Updates:

After adding javax.batch-api-1.0.jar file, the below exception is gone and the application is up an running.

Origianl Post

I have been using Java 6 along with Spring batch and Integration for a year by now. Application is a stand alone java application using Java 1.6.

Since the version of spring batch is so outdated, I am trying to update the libraries today. I upgraded,

  • Spring framework from 3.2 to 4.1.2
  • Spring batch from 2.1 to 3.0.2
  • Spring Integration from 2.2 to 4.1

Due to the upgrade, I added a new jar file which is Spring-retry-1.1.jar

After the upgrade, I am having below exception.

Caused by: java.lang.ClassNotFoundException: javax.batch.runtime.JobInstance
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)

It looks like spring batch core 3.0.2 does not support Java SE6 for me. It looks like Java EE7 package. However when I dig the spring batch document, it says it support Java 6,7,8.

Does anybody knows what is going on Spring batch core 3.0.2 with Java version?


Solution

  • This is not a java version issue - it looks your missing jars on your run-time class path

    How are you managing your dependencies? The spring batch 3.0.2 depends on a jar --> Javax.batch API that contains the class in question. http://mvnrepository.com/artifact/javax.batch/javax.batch-api

    For a list of full dependencies check out --> http://mvnrepository.com/artifact/org.springframework.batch/spring-batch-core/3.0.2.RELEASE

    Note the dependency is not optional. The Spring JobInstance class implements the JobInstance and as such is a required dependency.

    Class JobInstance

        All Implemented Interfaces:
        java.io.Serializable, javax.batch.runtime.JobInstance