FileNotFoundException error when file exists

I ran into this strange problem.

I am trying to read a file that is on another computer as a share:

\\remote-machine\dir\MyFileHere.txt

When I run the standalone application (16-line java file), everything is fine. But when I try to read the same file using the same class and the same method from the engine server (this is an application mechanism much like a Java EE application server, where you can run Java programs), "FileNotFoundException "rushes.

I, although I would be a kind of permissions, so I map the resource as a drive: K: \

Run my java file, read, excellent.

Run my java file inside "engine" -> FileNotFoundException.

When I copy a file to the local computer (C: \ MyFileHere.txt), no exception is thrown.

Question

What could be the reason for this FileNotFoundExcecption?

I am using Java 1.5

As far as I know, the mechanism pretty much uses Java transparently.

Has anyone come across something similar?

Additional question? What would be a good workaround? I'm starting to think that the tomcat installation serves these files and reads them through http, but I think too many, why is the SMB protocol in the first place, right? And probably I still won’t be able to open sockets.

Could there be a reason for the problem with the security manager (I have never used this before, but I know that it exists)

Instead, a SecurityException will be thrown, if so?

Many thanks.

EDIT

solved. Thanks to Steve W.

, "LaunchAnywhere" ZeroG. .exe, , , JVM .

Launcher. , - ( , ), , JVM-, SYSTEM. . . , NETWORK , , .

( ) , .cmd, . , .

"Process Explorer" SysInternals, , -.

!

, .

+3
4

? , ? Windows, Windows " ". . , .

+5

, "MyFileHere.txt", "MyFileHere.txt.txt" ,

0

, , ? , , .

Java, , Network Service .

, , . , , :) !

0

I had a similar problem. I think this is due to the way java resolves remote file URIs. Try the following and see if it works:

File: ////remote-machine/dir/MyFileHere.txt

I used the following example to check for a file in public folders in my field and worked:

public static void main(String[] args) throws URISyntaxException{
    URI uri = new URI(args[0]); //args[0] = File:////remote-machine/dir/MyFileHere.txt
    File f = new File(uri);
    System.out.print(String.format("File %1$s Exists? %2$s", args[0],f.exists()));
}
0
source

Source: https://habr.com/ru/post/1702347/


All Articles