3

On a particular server (Windows 2012 server R2) I am having trouble creating a temp file. I get the following error everytime I try.

java.io.IOException: The system cannot find the path specified
at java.io.WinNTFileSystem.createFileExclusively(Native Method)
at java.io.File.createTempFile(Unknown Source)
etc..

The error happens everytime the following code is ran:

InputStream inputStream = portalBean.createPDF( sessionID, foCode );

Things I have tried

  1. Changed the java.io.tmpdir variable on the fly. System.setProperty("java.io.tmpdir", "C:\\");

  2. Added -Djava.io.tmpdir=c:\\temp to the webnetwork lax file to an unrestricted location.

  3. I tried setting the webNetwork service to run as a specified user with rights to temp files e.g. the Administrator.

  4. Made sure I have free disk space and I cleaned out the c:\windows\temp folder.

  5. Made sure the tmp environment variables were set to their default values.

  6. I also tried running the service from a command prompt which was opened with the Run As Administrator option.

And the IOException lingers still. I have another server running the same code without issue (Windows Server 2012).

Does anyone else have any Ideas of what else I can try to resolve this issue? And or any tips on how I can debug the issue more thoroughly to get a grasp of what is going on?

9
  • Is this Java 6 or Java 7? Commented Mar 18, 2014 at 20:49
  • @fge Java 7 I believe. Commented Mar 18, 2014 at 20:51
  • In the 2012 server, in which folder ere the tmp file located? Commented Mar 18, 2014 at 20:52
  • @AndreaTaroni86 by default C:\Windows\Temp Commented Mar 18, 2014 at 21:00
  • Just one thing, are you sure your code actually uses the temporary directory at all? Commented Mar 18, 2014 at 21:01

2 Answers 2

4

One tool you can use to debug this is process monitor from system internal tool kit. The step is: add a filter to only monitor your process (I think it is javaw.exe in your case), after the error happens, go through the file activities in the process monitor log, you can find how the process is finding files and which directories the process searched. If the process is searching in the wrong directory, you can find it from the log.

I just used this tool to figure out a JVM crash problem today.

Based on the description of your problem, I guess the path variable of the process is changed in the middle of your code, with another tool process explore you can view the path variable of the process, it might help.

Sign up to request clarification or add additional context in comments.

Comments

1

Try and create instead a directory somewhere under your home directory:

final Path tmpdir = Paths.get(System.getProperty("user.home"), "tmp");
Files.createDirectories(tmpdir);
System.setProperty("java.io.tmpdir", tmpdir.toAbsolutePath().toString());

Then try and Files.createTempFile() in there.

Note that if Files.createDirectories() refers to an existing file which is not a directory, you'll get a FileAlreadyExistsException.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.