How Do I Resolve "does not denote a properly accessible directory" Exception with UNC Path?

A Spring boot application that implements Spring Integration is attempting to access a UNC path for it's inbound-channel-adapter.

The problem is that I'm receiving the following exception:

 13:29:52.925 [task-scheduler-10] ERROR o.s.i.handler.LoggingHandler -
 org.springframework.messaging.MessagingException: The path
 [\\server\sharepath] does not denote a properly accessible directory.

How do I resolve this issue?

Integration config

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:int="http://www.springframework.org/schema/integration"
       xmlns:int-file="http://www.springframework.org/schema/integration/file"
       xsi:schemaLocation="http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/integration/file http://www.springframework.org/schema/integration/file/spring-integration-file.xsd">

    <int-file:inbound-channel-adapter id="filesIn" directory="${input.path}" filename-regex="${file.pattern}">
        <int:poller id="poller" fixed-rate="500"/>
    </int-file:inbound-channel-adapter>

    <int-file:file-to-string-transformer input-channel="filesIn" output-channel="strings" delete-files="true" />

    <int:channel id="strings"/>

    <int:service-activator input-channel="strings"
                                   output-channel="output"
                                   ref="handler"/>

    <int-file:outbound-channel-adapter id="output"
                                       directory="${archive.path}"
                                       delete-source-files="true"/>

    <bean id="handler" class="com.giotta.service.DataHandler"/>

</beans>

The properties used in this config are inject with -D.

For example, java jar -Dinput.path="\\\\remote_host_ip\\path\\"

Answers


It would be better to share the config on the matter. That one for the inbound-channel-adapter which causes the problem for you.

Let's take a look to the code!

DefaultDirectoryScanner:

public final List<File> listFiles(File directory) throws IllegalArgumentException {
    File[] files = listEligibleFiles(directory);
    if (files == null) {
        throw new MessagingException("The path [" + directory
                + "] does not denote a properly accessible directory.");
    }
    return (this.filter != null) ? this.filter.filterFiles(files) : Arrays.asList(files);
}

protected File[] listEligibleFiles(File directory) {
    return directory.listFiles();
}

It's a place from where you see that error. It's reason is exactly in the java.io.File:

 * @return  An array of abstract pathnames denoting the files and
 *          directories in the directory denoted by this abstract pathname.
 *          The array will be empty if the directory is empty.  Returns
 *          {@code null} if this abstract pathname does not denote a
 *          directory, or if an I/O error occurs.
 *
public File[] listFiles() {

So, you really should be sure that you use correct path for your directory.

If you running your Boot application in the embedded Servlet Container mode, you should take into consideration the webapp working directory. In this case your \server\sharepath really should be absolute path, not relative.

UPDATE

See java.io.File JavaDocs:

* <li> For Microsoft Windows platforms, the prefix of a pathname that contains a drive
 * specifier consists of the drive letter followed by <code>":"</code> and
 * possibly followed by <code>"\\"</code> if the pathname is absolute.  The
 * prefix of a UNC pathname is <code>"\\\\"</code>; the hostname and the share
 * name are the first two names in the name sequence.  A relative pathname that
 * does not specify a drive has no prefix.

It turns out the UNC permissions was the issue. Since the windows service wrapper running the spring boot application was running as local user permissions was undeterminable.

I changed the user running the service to an actual user. This allowed spring integration to denote the accessibility.


Need Your Help

Java android simple http get method

java android http http-get

We are building an Android app to control a little light conneted to a webserver.

How to tell if two objects are identical?

javascript object

I mean not equal, but literally one....two things pointing to the same place in memory.