Monitoring events from a particular directory

Asked

Viewed 126 times

1

Hello,

I am developing an application that monitors events (create, delete and modify files) of a given directory.

I’m using the apache.commons.io.monitor library to assist me.

Generating the one . jar and running in a test folder works perfectly.

But when I play this one. jar inside the server (SYNOLOGY - Linux) and run, it recognizes the folder that is to monitor, but does not recognize any event. As if nothing was happening.

Class Main

public static void main(String[] args) {

    try {

        EntityManager em = EntityManagerFactorySingleton.getInstance().createEntityManager();

        File dir = new File("//volume1//CLIENTES");

        FileAlterationObserver fao = new FileAlterationObserver(dir);
        fao.addListener(new FileAlterationListenerImpl(em, dir));

        FileAlterationMonitor monitor = new FileAlterationMonitor(1 * 1000);

        monitor.addObserver(fao);
        monitor.start();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

And in my class Filealterationlistenerimpl it stores events in a Mysql database.

Is there any incompatibility of this library with Linux? I searched the documentation and found nothing.

  • How do you know that it recognizes the folder it is to monitor? That line File dir = new File("//volume1//CLIENTES"); shouldn’t have the diagonal bars "escaped" using backslash? For example "\\/volume1\\/CLIENTES" Search for escape sequences in Java.

  • Good afternoon, I know you are recognizing the correct folder because I did a test, printing on the console all folders within /volume1//CLIENTS and the result was what I expected.

  • I’m going to search for escape sequences

  • 1

    uses System.getProperty("file.separator") p/ have no doubts.

  • Even using System.getProperty("file.separator") remains the same. It recognizes the correct folder, but does not recognize any event.

  • Even if I map the server to Z:drive, it does not recognize any event

  • Guys, the problem is not in the path. In fact, it is even recognizing the events. However, it takes a random time to recognize these events. When set in code: new Filealterationmonitor(1 * 1000); it would be for it to monitor every second, but this is not happening on the server. Someone has a light?

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.