directory-watcher icon indicating copy to clipboard operation
directory-watcher copied to clipboard

Fails with NoClassDefFoundError inside Wildfly

Open Artur- opened this issue 1 year ago • 2 comments

When running inside Wildfly 27.0.1.Final, a call to waitAsync() fails with

12:01:30,947 ERROR [stderr] (default task-2) Caused by: java.lang.NoClassDefFoundError: com/sun/nio/file/ExtendedWatchEventModifier
12:01:30,947 ERROR [stderr] (default task-2) 	at deployment.project-base-flow-cdi-1.0-SNAPSHOT.war//io.methvin.watcher.DirectoryWatcher.register(DirectoryWatcher.java:454)
12:01:30,947 ERROR [stderr] (default task-2) 	at deployment.project-base-flow-cdi-1.0-SNAPSHOT.war//io.methvin.watcher.DirectoryWatcher.registerAll(DirectoryWatcher.java:433)
12:01:30,947 ERROR [stderr] (default task-2) 	at deployment.project-base-flow-cdi-1.0-SNAPSHOT.war//io.methvin.watcher.DirectoryWatcher.registerPaths(DirectoryWatcher.java:282)
12:01:30,947 ERROR [stderr] (default task-2) 	at deployment.project-base-flow-cdi-1.0-SNAPSHOT.war//io.methvin.watcher.DirectoryWatcher.watchAsync(DirectoryWatcher.java:229)
12:01:30,947 ERROR [stderr] (default task-2) 	at deployment.project-base-flow-cdi-1.0-SNAPSHOT.war//io.methvin.watcher.DirectoryWatcher.watchAsync(DirectoryWatcher.java:215)

The problematic code is

    WatchEvent.Modifier[] modifiers =
        useFileTreeModifier
            ? new WatchEvent.Modifier[] {ExtendedWatchEventModifier.FILE_TREE}
            : new WatchEvent.Modifier[] {};

and as it throws a NoClassDefFoundError, the case is not handled by

      } catch (UnsupportedOperationException e) {
        // UnsupportedOperationException should only happen if FILE_TREE is unsupported
        logger.debug("Assuming ExtendedWatchEventModifier.FILE_TREE is not supported", e);
        fileTreeSupported = false;
        // If we failed to use the FILE_TREE modifier, try again without
        registerAll(start, context);
      }

Artur- avatar Jul 03 '23 09:07 Artur-