• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Junilu Lacar
  • Martin Vashko
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Scott Selikoff
  • salvin francis
  • Piet Souris

WatchService on AS400 IFS folder path

 
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how to use WatchService to monitor as AS400 IFS path?

I got the basic WatchService working for local Windows and network paths, but not for AS400 IFS paths.

The IFS path is basically a network path which I can access using some login. Assuming I logged successfully.



For Java 8
java.io.IOException: The request is not supported.

at sun.nio.fs.WindowsWatchService$Poller.implRegister(Unknown Source)
at sun.nio.fs.AbstractPoller.processRequests(Unknown Source)
at sun.nio.fs.WindowsWatchService$Poller.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

For Java 7
Exception in thread "Thread-2" java.lang.AssertionError: Should not get here
at sun.nio.fs.WindowsFileAttributes.volSerialNumber(WindowsFileAttributes.java:387)
at sun.nio.fs.WindowsWatchService$Poller.implRegister(WindowsWatchService.java:362)
at sun.nio.fs.AbstractPoller.processRequests(AbstractPoller.java:260)
at sun.nio.fs.WindowsWatchService$Poller.run(WindowsWatchService.java:533)
at java.lang.Thread.run(Thread.java:745)

Both version error comes from the line
 
Sheriff
Posts: 21821
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure it's possible. A WatchService is tied to the file system, and I doubt that there's support for network shares there. Unlike NTFS and EXT*, it probably doesn't have a notification mechanism. I actually think it's bad design to let File and the default FileSystem handle network shares. Sure, it's easier, as long as you don't need anything "exotic" like WatchService or even logging in.
 
K. Tsang
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob for your quick reply.

I'm sure that's a easier way to achieve what I need to do. Will think of something other approach.
 
Marshal
Posts: 14460
240
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting problem. My inner MacGyver is whispering "cron, rsync or diff, and touch" but that would involve a separate process from the JVM. Plus, you're on a Windows system so...  ¯\_(ツ)_/¯
 
Rob Spoor
Sheriff
Posts: 21821
104
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could try a third party library like Apache Commons IO; it has FileAlterationMonitor. That uses polling though, so it's not as efficient as WatchService, but I doubt you'll find anything that does not use polling.
 
K. Tsang
Bartender
Posts: 3648
16
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the feedback.

I ended up not using WatchService for the IFS folder but just to check for a particular file. If that file isn't there, sleep X, kind of like a while loop for say 30min or dedicated file whichever is earlier.
 
Too many men are afraid of being fools - Henry Ford. Foolish tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!