I'm trying to Create a directory structure with java, in a remote UNC location.
java is running in a linux machine and the windows network path is mapped with SAMBA server.
Issue is :
When creating the directories it creates the first directory : OK
Try to create the first sub directory inside the first directory : FAILS
Because it takes some time (nearly 2 seconds) to show up the first directory through samba.
This could be due to the slowness of the network (but it's unavoidable )
If i execute the same code step by step (debugging) it works normally and create the directory structure.
Please help me.
I need some mechanism which will wait java mkdir() function until the initially created directory
get showed up in the UNC path.
Related
Bear with me cause I'm new to java and stackoverflow.
Problem:
I have a jar that is reading a file from the environment variable of its machine(Server A).
If I remote Server A and run this jar, the file reading is ok.
But I needed to put this jar and a batchfile to execute it in a SHARED FOLDER to be able to access it without the need to remote Server A.
For the batchfile in the shared folder with "java -jar "%~dp0MYJAR.jar"
Adding %~dp0 in front of jar name in batchfile allowed me to call the jar in shared folder. [source in link below]
Can I run a jar file from shared folder of remote system just by double clicking from my system?
But when running the jar, the jar was not able to locate the file its reading in Server A. Here's the code on reading the file.
Properties prop2 = new Properties();
String propFile=System.getenv("OTHERS_HOME") + "\\conf\\FILE_TO_READ.txt";
upon printing the current directory when the jar is running.
When remote access to Server A i got E:\ISO_Tester. This is the correct path.
But when running in my machine from a shared folder of Server A i got C:\Windows which I think is from my local machine instead of Server A.
The best part is that you should be sharing from server A the JAR file and the required files as well and write/execute the code with respect to the relative path of file
It is because the batch will not access the properties of server A, instead takes whatever available from machine where it is being executed
If you want to read more please refer this link for Get remote env vars using Windows Powershell
I'm having a trouble accessing some files in universal way across app run modes.
I have folder "resources" in app root folder, which contains some crucial files.
When I run in dev mode, I access them in simple manner, like:
Play.application().path().getAbsolutePath()+"/resources/file.file";
But after I package my app via dist commmand (I've modified build.sbt so that "resources" folder is copied near conf and lib folders), the code above stops working, due to this line
Play.application().path().getAbsolutePath()
now returns a path to bin folder, in which app.bat is ran from. So if in dev mode, the code above returns correct path like X:/app/resources/file.file, in prod mode it's like X:/app/bin/resources/file.file which is incorrect.
P.S. I absolutely can't put my files in conf folder and access them as a resource from a classloader because of numerous reasons which are actually not important.
So the question is simple as that: how to access these file resources in a universal manner across modes, without any hardcoding.
TY in advance.
There is a method on Application which lets you access files in the application root.
https://playframework.com/documentation/2.4.x/api/java/play/Application.html#getFile-java.lang.String-
default java.io.File getFile(java.lang.String relativePath)
Get a file relative to the application root path.
Parameters: relativePath - relative path of the file to fetch
Returns: a file instance - it is not guaranteed that the file exists
Since you already have the application, you should be able to use this method to directly access the file.
I have a file on linux ubuntu server hosted with path name /home/kishor/project/detail/.
When I made a web app in window to upload and download file from specified location i used path "c:\kishor\projects\detail\" for saving in window.
For my surprise when i used window file path name in my server i am still able to get files and upload them, i.e, "c:\kishor\projects\detail\".
Can anyone explain why it is working (as window and linux both use different file path pattern).
I've seen this work too. What linux does is create a file whose name is literally c:\kishor\projects\detail\
If you say, you can "upload" files... perhaps there is now a new folder structure.
Some months ago i saw a similar thing: Under /home/webadmin was an new structure "/c:/Users/...."
I want to make JMeter distributed testing. It was said in the manual that first I should start jmeter-server on remote nodes, and then I should update jmeter.config and run jmeter on a master node.
I did all these steps. My test plan includes working with CSV-config files. If I test just from 1 (master) node - then everything works as a charm. But when I try distributed testing all tests fail. Some investigation showed that remote nodes send requests without substitution of ${..}-like parameters. Requests look like
POST data:
5|0|6|http://host.com/portal/|67D1C612DCF291DCD0F71AD15E404F37|host.ui.client.services.LoginService|login|java.lang.String/2004016611|${ADMIN_LOGIN}|1|2|3|4|3|5|5|5|6|6|1|
It's obvious that remote jmeter-server cannot find the CSV-file. Where should I put it?
P.S: I have machines with different OS (Windows 7 and Ubuntu 10.04).
The easiest way to resolve the multiple OS issue is to put the CSV file in the Jmeter BIN directory on all test machines, and do not reference the path in the CSV Data Set Config component.
Put a full path and filename into your 'CSV Data Set Config' component, eg. c:\loadtest\config.csv and ensure that you put the CSV file in the place that is specified.
The components manual also states the following:
Relative file names are resolved with respect to the path of the active test plan.
So it should be possible to put the file in the same directory as the test plan file. This ought to work in both Linux and Windows.
Any reference to data file assumes that such a file exists in respective nodes in the specified path. For example, if you have your CSV files in C:\data, then when you execute the test plan in a distributed fashion, the testplan would look for the data file in C:\data of the node (the slave).
In effect, if you are using 10 slave machines, you need to have c:\data folder in all those 10 machines.
There is no need to copy test plan.
EDITED because the docs reference was wrong - I got burned by my own answer :)
Old question, but I just ran into this issue and the answers here are conflicting.
Is a relative path resolved to the bin/ directory, or to the directory of the current .jmx test script?
Answer: it is only the directory of the test script. From the docs:
Relative file names are resolved with
respect to the path of the active test plan. Absolute file names are
also supported, but note that they are unlikely to work in remote
mode, unless the remote server has the same directory structure. If
the same physical file is referenced in two different ways - e.g.
csvdata.txt and ./csvdata.txt - then these are treated as different
files. If the OS does not distinguish between upper and lower case,
csvData.TXT would also be opened separately.
I have an Java application for copying large amounts of data from users' workstations to a server. The java.io.File class is supposed to work with UNC paths very well and in fact it does but only when I run the app in standard execution model.
When the application is launched via Web Start I get a FileNotFoundException when trying to open a FileOutputStream with "The network path was not found" in message. Again everything works fine when I download the jar to the PC and lauch it from command line.
My app is signed and i define all-permissions in JNLP.
Edit: I have also discovered that when I map the UNC path to a drive letter it works too.
There is no solution to this. I ended up mounting the path as a named volume and using it trough the volume.