Search code examples
javafxjxbrowser

JXbrowser initialization fails when run in empty folder: java.nio.file.NoSuchFileException:...jxbrowser-browser.log.lck


OS: macOS Sierra 10.12.3 (16D32)

jxbrowser version: 6.14.2

I set jxbrowser cache and logs directory to the single folder near the executed jar file. When it run from scratch an exception rises: java.nio.file.NoSuchFileException:...jxbrowser-browser.log.lck

If run the previous version (6.3) and after that the current one, then everything works correct.

[DEBUG] 2017-07-30 15:55:00.411 [main] ScalarSelectOperation - select from result set
Exception in Application init method
java.lang.RuntimeException: Exception in Application init method
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:912)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$155(LauncherImpl.java:182)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.nio.file.NoSuchFileException: /%PATH_TO_JAR_FOLDER%/.cache/jxbrowser-browser.log.lck
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.newFileChannel(UnixFileSystemProvider.java:177)
    at java.nio.channels.FileChannel.open(FileChannel.java:287)
    at java.nio.channels.FileChannel.open(FileChannel.java:335)
    at java.util.logging.FileHandler.openFiles(FileHandler.java:459)
    at java.util.logging.FileHandler.<init>(FileHandler.java:292)
    at ru.mybetter.ui.desktop.BetterClient.redirectLogMessagesToFile(BetterClient.java:174)
    at ru.mybetter.ui.desktop.BetterClient.init(BetterClient.java:106)
    at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:841)
    ... 2 more

2017-07-30 15:55:00,610 pool-2-thread-1 DEBUG Stopping LoggerContext[name=2a139a55, org.apache.logging.log4j.core.LoggerContext@f5a3839]
2017-07-30 15:55:00,611 pool-2-thread-1 DEBUG Stopping LoggerContext[name=2a139a55, org.apache.logging.log4j.core.LoggerContext@f5a3839]...

Solution

  • According to the exception stack trace the error comes from:

    ru.mybetter.ui.desktop.BetterClient.redirectLogMessagesToFile(BetterClient.java:174)
    

    I suppose you create FileHandler instance with an invalid path to the file that doesn't exist. Or, according to Javadoc of the FileHandler(String pattern) the IOException can be thrown from its constructor when there are IO problems opening the files.

    Please make sure that the path to the file you pass to the FileHandler constructor is accessible from your Java program and there are no read/write permission issues with it.