Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7643949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:34:15+00:00 2026-05-31T09:34:15+00:00

I have a problem with Commons VFS. I want to connect to a directory

  • 0

I have a problem with Commons VFS. I want to connect to a directory using SFTP and list it. Here is the code:

FileSystemOptions opts = new FileSystemOptions();
SftpFileSystemConfigBuilder.getInstance().setStrictHostKeyChecking(opts, "no");
FileSystemManager fsManager = VFS.getManager();

FileObject sourceDir = fsManager.resolveFile(sourceUrl, opts);
FileObject targetDir = fsManager.resolveFile(config.get("to"));

for (FileObject sourceFile : sourceDir.getChildren()) { // here is the problem
    FileObject targetFile = fsManager.resolveFile(targetDir + "/" + nodeName + "_"
            + sourceFile.getName().getBaseName());
    logger.debug("Copying files. Source: " + sourceFile.getName().getPath() + " Target: "
            + targetFile.getName().getPath());
}

It seems that the fsManager resolves it correctly but getChildren() fails. I found out that the sourceDir is an IMAGINARY type; the following code says it

logger.debug(sourceDir.getType());

I checked the file and it’s an ordinary folder – not a link or something like that.

Error

org.apache.commons.vfs2.FileNotFolderException: Could not list the contents of "sftp://path/to/dir" because it is not a folder.
    at org.apache.commons.vfs2.provider.AbstractFileObject.getChildren(AbstractFileObject.java:693)
    at pkg.services.impl.QuartzJobEventLog.downloadEventLogs(QuartzJobEventLog.java:64)
    at pkg.services.impl.QuartzJobEventLog.executeJob(QuartzJobEventLog.java:37)
    at pkg.services.impl.AbstractQuartzJob.execute(AbstractQuartzJob.java:25)
    at $QuartzJob_1360635dbcd.execute($QuartzJob_1360635dbcd.java)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:203)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:520)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:34:16+00:00Added an answer on May 31, 2026 at 9:34 am

    According to the documentation getting “directory contents” is not supported for the SFTP filesystem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem using JPA with Oracle and grouping by hour. Here's the
I have a problem with the Jakarta Commons HttpClient. Before my self-written HttpServer gets
I have problem with my query on C, I’m using the oci8 driver. This
I have a working prototype of a Java application that is using Apache Commons
I have a problem with a really slow connection between my Java code and
I have a problem with Tomcat 5.5 and Java EE webapp libraries. I'm using
Here is my problem. I have a bunch of Configuration classes that get serialized
Hi i am using commons collections generics 4.01. I have a dto object. Class
I have added org.apache.commons.fileupload and org.apache.commons.io package into the WEB-INF/lib directory of my project
We have a module which will send reminder mail. We are using apache commons

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.