We had a similar problem on our test server. Looks like a file permissions issue, i.e. Spring Batch Admin is trying to create a directory structure for "target / config", but the user is not allowed to create directories.
This is the chain causing the problem:
META-INF/spring/batch/bootstrap/integration/configuration-context.xml contains a file polar definition that refers to a property:
<file:inbound-channel-adapter directory="${batch.job.configuration.file.dir}" channel="job-configuration-files" filename-pattern=".*\.xml"> <poller max-messages-per-poll="1" cron="5/1 * * * * *" /> </file:inbound-channel-adapter>
Checking the documentation of the inbound adapter channel shows the following (spring-integration-file-2.1.xsd):
<xsd:attribute name="directory" type="xsd:string" use="required"> <xsd:annotation> <xsd:documentation><![CDATA[Specifies the input directory (The directory to poll from) eg: directory="file:/absolute/input" or directory="file:relative/input"]]></xsd:documentation> </xsd:annotation> </xsd:attribute>
and (!)
<xsd:attribute name="auto-create-directory" type="xsd:string" default="true"> <xsd:annotation> <xsd:documentation> Specify whether to automatically create the source directory if it does not yet exist when this adapter is being initialized. The default value is 'true'. If set to 'false' and the directory does not exist upon initialization, an Exception will be thrown. </xsd:documentation> </xsd:annotation> </xsd:attribute>
So, as a result, auto-create-directory true, and Spring is trying to create a (relative) directory structure somewhere in the path of your server shell.
For an error message, checking the java class org.springframework.integration.file.FileReadingMessageSource class gives an explanation:
if (!this.directory.exists() && this.autoCreateDirectory) { this.directory.mkdirs(); } Assert.isTrue(this.directory.exists(), "Source directory [" + directory + "] does not exist.");
The javadoc java.io.File.mkdirs() says:
public boolean mkdirs() Creates the directory named by this abstract pathname, including any necessary but nonexistent parent directories. Note that if this operation fails it may have succeeded in creating some of the necessary parent directories. Returns: true if and only if the directory was created, along with all necessary parent directories; false otherwise
So what happens, mkdirs () returns false because it could not create a directory. The following exists () also returns false, returning an error message, as indicated in the original message.
A workaround is to set the parameter to an existing and writable directory, for example, "/ tmp" using an absolute path. Unfortunately, I have no idea how this Spring function should work if you save your job definitions in the classpath; it would be wiser not to use the file field, but to use the "polpath-aware" file poller ...