This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Batch is unable to write to files

Jan 11th, 2013, 04:30 PM

Hello,
So I have been working with the Sample Batch project provided by STS using Spring Batch 2.1.7 along with Spring Web Admin 1.2.0 and I was able to create several jobs that cover reading/writing delimited flat files, xml files, and database. Everything is working fine. Now I am configuring Spring Batch Web Admin as a completely seperate project and I imported the jobs I created in my other Spring Batch project to this one. I am able to successfully run the database jobs fine, but any jobs that work with writing files are not working as expected. For both flatfile and xml jobs, I read from a flatfile/xml file and write to another flatfile/xml file. When I execute the job via batch web admin, the web admin says that the job executed successfully and says that the appropriate number of reads and writes are successful. The problem is when I check the classpath to look for these written files, they are NOT THERE! In the other Batch project, it works fine. In this batch web admin project, the files are not getting written to classpath/src/main/resources. Below is a sample of the XML job. Any help is greatly appreciated. Thanks!

This problem is probably related to the fact that I am executing batch within a web container as opposed to executing the commandlinerunner as I was doing previously right? I tried pointing the resource to file:/tmp/productsWrite.xml" and it was not able to write it there either. I am using Tomcat 7. Any help would be greatly appreciated. Thanks!

I wouldn't expect you to be able to write to a classpath location within a container. That being said, is Tomcat running under a user's name that has permissions to write to the directories you are trying to write to? Also, what is the exception being thrown when the ItemWriter tries to open the file?