开发者

Writing to temp dir fails when running as SYSTEM on Win7

We have a Java application that includes components that run as SYSTEM on Windows machines. On Windows 7 x64, on开发者_如何学编程e 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.


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.


Have you tried setting java.io.tmpdir to a different venue, as discussed here? As noted here and here, you can change the default used by createTempFile() when starting the Java Virtual Machine:

java -Djava.io.tmpdir=/path/to/tmpdir

Because this approach is potentially insecure and host platform specific, it should only be used while tracking down the actual problem, for example.


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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜