Question

We have a Java application that includes components that run as SYSTEM on Windows machines. On Windows 7 x64, one component fails when trying to unpack the jnidispatch library:

Exception in thread "main" java.lang.Error: Failed to create temporary file for
jnidispatch library: java.io.IOException: The system cannot find the path
specified
    at com.sun.jna.Native.loadNativeLibraryFromJar(Native.java:600)
    at com.sun.jna.Native.loadNativeLibrary(Native.java:550)
    at com.sun.jna.Native.<clinit>(Native.java:87)
    at falcon.util.vmware.VcmdTwo.loadLibraries(VcmdTwo.java:53)

Copied below is a snippet of the comments from the Native class from the jna library:

When JNA classes are loaded, the native shared library (jnidispatch) is loaded as well. An attempt is made to load it from the system library path using {@link System#loadLibrary}. If not found, the appropriate library will be extracted from the class path into a temporary directory and loaded from there.

OK, so far so good: Java is trying to unpack jnidispatch.dll into whatever java.io.tmpdir points at. The problem seems to be that java.io.tmpdir points to C:\Windows\system32\config\systemprofile\AppData\Local\Temp\ for that particular process. This directory exists and SYSTEM has Full Control. However, extraction of the jnidispatch DLL to that directory always fails. If I modify the code in our app to manually write files to that same directory, the writes succeed.

I've looked over the relevant Java and JDK code and don't see any obvious misbehavior, so I'm forced to conclude that this is some weird Win7 UAC-related bug, but darn if I can figure out what it is. Any suggestions would be most welcome.

Was it helpful?

Solution

Are you 100% certain that it is writing to where you think it is writing? Given that if you modify the program to force it to write to there and it works it sounds like you are trying to write to another directory.

OTHER TIPS

Have you tried setting java.io.tmpdir to a different venue, as discussed here?

Writing a file could fail due to following reasons:
1. user permission/s (inheritance manhandled).
2. corrupt file (already present).
3. file being accessed by another application at the same time.
4. file being locked by anti-malware / anti-virus software.

i had the problem. strangely my antivirus detected jndispatch.dll file as an unclean file and dumped it to its vault.
may be the inbuilt windows defender is to doing the same thing.

check out!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top