Results 1 to 6 of 6

Thread: Spring Batch Execution From Command Prompt

  1. #1
    Join Date
    Aug 2011
    Posts
    16

    Default Spring Batch Execution From Command Prompt

    Hi All

    Can any one tell me how to execute the Spring Batch through Command Prompt.

    What I have done so far.

    I created the batch jar ---- XYZ.jar

    And i want to execute it using

    Code:
    java org.springframework.batch.core.launch.support.CommandLineJobRunner vpb-context.xml paymentRecordLoadJob;
    But every time i am getting the same Exception

    Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/batch/core/launch/support/CommandLineJobRunner
    Caused by: java.lang.ClassNotFoundException: org.springframework.batch.core.launch.support.Comm andLineJobRunner
    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)
    Could not find the main class: org.springframework.batch.core.launch.support.Comm andLineJobRunner. Program will exit.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    Well what does the stack trace tell you... The classes aren't on the class path (I suggest a read off the java guide on how to specify the class path)... Currently only the classes in the current directory are available nothing more nothing less...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Aug 2011
    Posts
    16

    Default

    I am not getting one thing , I have my classes in XYZbatch.jar and Spring says that it has a class "CommandLineJobRunner" in spring-batch-core-2.1.0.RELEASE.jar from which we can execute batch using "java org.springframework.batch.core.launch.support.Comm andLineJobRunner vpb-context.xml paymentRecordLoadJob".
    So what should be in classpath , what needs to be where and how the references will take place. Please help me it imp for me

    Thanks for your quick response Marten

  4. #4
    Join Date
    Aug 2011
    Posts
    16

    Default

    Below is my bat file content


    set JAVA_HOME=%~dp0..\jre
    set CLASSPATH=%JAVA_HOME%\lib
    set Path=%JAVA_HOME%\bin;%path%

    set CLASSPATH=lib\activation.jar;lib\aopalliance-1.0.jar;lib\commons-dbcp.jar;lib\commons-lang-2.4.jar;lib\commons-logging.jar;lib\commons-pool.jar;lib\db2jcc.jar;lib\db2jcc4.jar;lib\db2jcc _license_cisuz.jar;lib\ibatis-2.3.4.726.jar;lib\jaxb-api.jar;lib\jaxb-impl.jar;lib\jaxb-xjc.jar;lib\jettison-1.3.jarlib\log4j-1.2.16.jar;lib\ojdbc14.jar;lib\org.springframework .aop-3.0.3.RELEASE.jar;lib\org.springframework.asm-3.0.3.RELEASE.jar;lib\org.springframework.beans-3.0.3.RELEASE.jar;lib\org.springframework.context-3.0.3.RELEASE.jar;lib\org.springframework.context. support-3.0.3.RELEASE.jar;lib\org.springframework.core-3.0.3.RELEASE.jar;lib\org.springframework.expressi on-3.0.3.RELEASE.jar;lib\org.springframework.jdbc-3.0.3.RELEASE.jar;lib\org.springframework.orm-3.0.3.RELEASE.jar;lib\org.springframework.transact ion-3.0.3.RELEASE.jar;lib\spring-batch-core-2.1.0.RELEASE;lib\spring-batch-infrastructure-2.1.0.RELEASE;lib\spring-batch-test-2.1.0.RELEASE;lib\stax-api-1.0.1;lib\xstream-1.3;VendorPortalBatch.jar


    java -classpath %CLASSPATH% org.springframework.batch.core.launch.support.Comm andLineJobRunner vpb-context.xml paymentRecordLoadJob schedule.date=2011/09/02


    pause;


    Kindly let me know where to keep what.

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    You don't have the jars on your class path.. (And please use [ code][/code ] tags!).

    Code:
    set CLASSPATH=lib\activation.jar;lib\aopalliance-1.0.jar;lib\commons-dbcp.jar;lib\commons-lang-2.4.jar;lib\commons-logging.jar;lib\commons-pool.jar;lib\db2jcc.jar;lib\db2jcc4.jar;lib\db2jcc _license_cisuz.jar;lib\ibatis-2.3.4.726.jar;lib\jaxb-api.jar;lib\jaxb-impl.jar;lib\jaxb-xjc.jar;lib\jettison-1.3.jarlib\log4j-1.2.16.jar;lib\ojdbc14.jar;lib\org.springframework .aop-3.0.3.RELEASE.jar;lib\org.springframework.asm-3.0.3.RELEASE.jar;lib\org.springframework.beans-3.0.3.RELEASE.jar;lib\org.springframework.context-3.0.3.RELEASE.jar;lib\org.springframework.context. support-3.0.3.RELEASE.jar;lib\org.springframework.core-3.0.3.RELEASE.jar;lib\org.springframework.expressi on-3.0.3.RELEASE.jar;lib\org.springframework.jdbc-3.0.3.RELEASE.jar;lib\org.springframework.orm-3.0.3.RELEASE.jar;lib\org.springframework.transact ion-3.0.3.RELEASE.jar;lib\spring-batch-core-2.1.0.RELEASE;lib\spring-batch-infrastructure-2.1.0.RELEASE;lib\spring-batch-test-2.1.0.RELEASE;lib\stax-api-1.0.1;lib\xstream-1.3;VendorPortalBatch.jar
    The part in blue doesn't point to a jar file but to well something that probably isn't a jar and neither a dir that contains classes. There are more of those 'paths' on your class path which point to well nowhere...
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  6. #6
    Join Date
    Aug 2011
    Posts
    16

    Default

    Thanks a lot Marten

    Although it was a silly mistake but u examined very well.

    Thanks once again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •