cancel
Showing results for 
Search instead for 
Did you mean: 

java mapping write file - path problem

peter_wallner2
Active Contributor
0 Kudos

Hello experts,

I have a java mapping that writes a file onto the file system of the JEE server.

The path in the mapping I specified like this:

File file= new File("../temp/myfile.txt");

I expect it being in

/usr/sap/<SAPSID>/<Instance>/j2ee/cluster/temp

But the file is always saved under "../cluster/server0/myfile.txt" or "../cluster/server1/myfile.txt"

How can I solve this?

I also tried

File file= new File("../server0/myfile.txt");

expecting it to always be saved under "server0" but it is either saved in "server0" or "server1".

Thank you for your help,

Peter

Accepted Solutions (1)

Accepted Solutions (1)

former_member184681
Active Contributor
0 Kudos

Dear Peter,

Did you simply try to specify the full path in your Java code? I believe what you observe is caused by Java runtime environment variables - they specify the root path for Java runtime, and when you specify a relative path, it is evaluated against this root path.

Regards,

Greg

Regards,

Greg

Answers (1)

Answers (1)

anupam_ghosh2
Active Contributor
0 Kudos

Hi Peter,

             I guess you are trying to write the file in system where OS is either LINUX/UNIX.  you must be are aware of  symbolic links, a feature of UNIX/LINUX operating system. Thus if you are specifying a path which has got a symbolic link /soft link in it the actual file will be written in the directory where the links point to. More on this you can see here .    To prevent this problem, find out whether the path you are specifying has a symbolic link in it or not. Log in to the system at operating system level and check in to the directory where you want to write the files. While you move from one directory to another check if there is a symbolic link or not. The symbolic links can be identified by the out of "ls" command. This has been expalined in the link I provided here. Once you find the links  then remove those links from the URL you are specifying in your java code  and replace it with absolute path. Hope this resolves your problem.

Regards

Anupam

peter_wallner2
Active Contributor
0 Kudos

Hello Anupam,

I tried giving it the full path like Grzegorz suggested and I also tried to follow your approach with Basis people but both was not a success. Now I set up an alternative, deleted the java mapping and made an adapter module instead. That connects to an FTP and writes the file which is working fine.

Thank you for your help and best regards,

Peter