How to solve FileNotFoundException: Invalid file path

This article discusses how to solve the JDK issue, which happens on WildFly on Windows, on certain JDK version, an results in the error “java.io.FileNotFoundException: Invalid file path“.

The Issue

As discussed in this JDK Bug , with java update cpuapr2022 (8u331 11.0.15 and 18.0.1), the Web Server undertow is broken for windows.

When using a JDK affected by this Bug, a FileNotFoundException is thrown when a user is logging into the management console. The management console is no longer available .

Caused by: java.io.FileNotFoundException: Invalid file path
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:231)
        at java.base/java.io.FileOutputStream.<init>(FileOutputStream.java:126)

The Solution

You can solve the issue in two ways:

  1. Upgrade to the JDK version which solves the issue. Check the Fix version from the above Bug.
  2. Apply a workaround to change the property jdk.io.File.enableADS to true instead of false.

The java property jdk.io.File.enableADS is a hidden system property used by the Java Virtual Machine (JVM) to enable or disable the Advanced Disk Storage (ADS) feature. ADS is a feature that allows the JVM to store objects in a more compact and efficient manner, which can improve the performance of Java applications.

  • When jdk.io.File.enableADS is set to true, the JVM will attempt to use ADS for storing objects. This can result in a significant performance improvement for some applications, especially those that perform a lot of object creation and garbage collection. However, it is important to note that ADS is still experimental, and it may not work well with all applications.
  • When jdk.io.File.enableADS is set to false, the JVM will not use ADS. This will cause objects to be stored in the traditional way, which may result in a slightly slower performance. However, it is also more reliable, and it is less likely to cause problems with applications.

In general, it is recommended to set jdk.io.File.enableADS to true for applications that are performance-critical and that have been tested with ADS. For other applications, it is generally safe to leave it at the default value of false.

In order to modify the property, you can set jdk.io.File.enableADS to true in the standalone.conf.bat if you are running in standalone mode:

set "JAVA_OPTS=%JAVA_OPTS% -Djdk.io.File.enableADS=true"   

On the other hand, if you are using Domain mode, you can set it in the scope you need it (Server/Server Group/Host) with a jvm element:

<jvm options="-Djdk.io.File.enableADS=true">

More about Domain Mode configuration here: How to configure WildFly in Domain mode

Conclusion

This article was a quick wiki to solve the issue FileNotFoundException which happens for some JDK version running WildFly on WIndows

Found the article helpful? if so please follow us on Socials