Search code examples
javatomcatvfsapache-commons-vfs

Process existing files on startup in a folder with VFS2


I have multiple FileListeners that process all the files which are inserted in remote folders using the org.apache.commons.vfs2 library.

Sometimes I have to stop Tomcat, so if new files are inserted in the folders, they will not be processed although I start my WebService after they have been inserted.

I have been doing some research and the following URLs[1][2] force me to hard code the folder's location and I don't know how well It would work with multiple Listeners at the same time processing.

Is there a better way to configure the FileListener on startup? Thanks.

  1. Tomcat after Startup Event with spring

  2. Callback on tomcat server startup complete


Solution

  • I have fixed this issue with not a beautiful way. I create on startup a new thread in one webapp , sleep it , and then after Tomcat startup, process the existing files.