Support for Windows Server (2016)
See original GitHub issueCalling appDirs.getUserDataDir()
throws an Exception on Windows Server 2016 (and maybe other versions of Windows Server):
java.lang.NoClassDefFoundError: Could not initialize class com.sun.jna.Native
at com.sun.jna.platform.win32.Shell32.<clinit>(Shell32.java:32)
at com.sun.jna.platform.win32.Shell32Util.getFolderPath(Shell32Util.java:44)
at com.sun.jna.platform.win32.Shell32Util.getFolderPath(Shell32Util.java:61)
at net.harawata.appdirs.impl.ShellFolderResolver.resolveFolder(ShellFolderResolver.java:47)
at net.harawata.appdirs.impl.WindowsAppDirs.getLocalAppData(WindowsAppDirs.java:75)
at net.harawata.appdirs.impl.WindowsAppDirs.getUserDataDir(WindowsAppDirs.java:33)
at net.harawata.appdirs.AppDirs.getUserDataDir(AppDirs.java:20)
I was able to reproduce this exception on a new clean VM with just a Test-Application only calling this method. I tested with Java 9 and Java 14, both have the same Issue. I’m using the latest 1.2.0-Version.
On my Windows 10 System everything works fine.
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Windows Server 2016 - Microsoft Lifecycle
Support Dates ; Windows Server 2016, Oct 15, 2016, Jan 11, 2022 ...
Read more >EOL Windows Server | End of Life (EOL) | Microsoft | Lifecycle
Release Release date End of life Extended Support
Windows Server 2019 Datacenter November 13, 2018 January 9, 2024 January 9, 2029
Windows Server 2019 Essentials...
Read more >Microsoft Windows Server | endoflife.date
Release Released Active Support
Windows Server 2022 1 year and 4 months ago. (18 Aug 2021) Ends in 3 years and 9 mo...
Windows Server...
Read more >The End of Mainstream Support is a Time to ... - DirTeam.com
Windows Server 2016 is in mainstream support starting today. Not only does this mean that this particular Windows Server only gets security ...
Read more >What is Windows Server 2016? - TechTarget
However, mainstream support for Windows Server 2016 ended on Jan. 11, 2022. This means that the OS only receives security updates, but no...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
wow, I did a really dumb mistake: I overlooked that somewhere in this huge pom.xml an older version of jna was added as a dependency, which contained this Windows Server Bug… Fixed this just by updating… Thanks for your help.
JNA uses a DLL to access native API and, according to their doc, it’s auto-unpacked at runtime. http://java-native-access.github.io/jna/5.6.0/javadoc/overview-summary.html#loading
And the test result shows that the problem occurs when unpacking the DLL or when loading the unpacked DLL.
I am not sure why it occurs only on Windows Server, but you should probably try building the fat-jar using the spring-boot-maven-plugin if you haven’t. Unlike maven-shade-plugin, it includes dependencies as JARs, so it could make a difference.
If it still didn’t solve the problem, I would suggest posting a question to JNA’s mailing list or Stackoverflow. Someone who is familiar with JNA may have an answer.