mukesh.y@gmail.com (2) [Avatar] Offline
#1
Hi - I bought this book last week and still struggling to get the sample code running. I can compile it fine and while running it is giving this error :

77-56$ java -jar ch01-1.0.0.jar
Failed to load Main-Class manifest attribute from
ch01-1.0.0.jar.

Please let me know, am I doing something wrong.

Thanks.
arnaud.cogoluegnes (73) [Avatar] Offline
#2
Re: how to run sample code
Hi!

Chapter 1 covers how to launch the job from a JUnit test (thus from Eclipse or Maven). You can learn more about launching jobs in chapter 4 (the command line is covered).

The ch01-1.0.0.jar file you packaged contains only the definition of the job (classes + XML configuration), not the class to launch the job. There's such a launching class in Spring Batch itself, CommandLineJobRunner (chapter 4 covers all of this).

If you're using Maven, here's a trick to launch the batch from the command line, with the Maven exec plugin. Launch the following command (update your code from http://code.google.com/p/springbatch-in-action/ , I've just added the necessary configuration file!):

mvn exec:java -Dexec.mainClass="org.springframework.batch.core.launch.support.CommandLineJobRunner" -Dexec.args="job-context.xml importProducts inputResource=classpath:/input/products.zip targetDirectory=./target/importproductsbatch/ targetFile=products.txt" -Dexec.classpathScope="test"

you won't see much, as the database lives only for the test execution, but you should see the uncompressed file in the target/importproductsbatch directory.

hope that helps and thanks for your interest in the book.