I have a program where I actively ping the contents of a directory using nio.WatchService.
Anytime a new file is added there, I process some custom logic. The path to the folder is read from a properties file and has the following format:
pathvar=C:\\files\\in\\ -->works on local
pathvar=\\\\serv123\\Share\\input\\ --> works on local
Both formats run fine on win 7 local (command line and through IDE). When
executed on a win 2008 R2 server, the program executes when path variable is local - no (mapped) network paths work.
pathvar=C:\\\\files\\in\\ -->works
pathvar=\\\\serv123\\Share\\input\\ --> does not work
pathvar=N:\\Share\\input\\ --> N: mapped to serv123 does not work
Code is same as listed here:Watching a Directory for Changes in Java
I don't get any exceptions either, but UNC paths are not working. Any help is appreciated.
Edit: The way I deducted the issue was path related(in absence of any exceptions), is by playing around with the paths.
I packaged it as a jar and run it on the command window as
java -jar myjar.jar
With pathvar=C:\files\in\, the programs runs and waits
With pathvar=\\server\files\in\, it quits immediately/
Related
We're experiencing a strange issue - has anybody seen anything similar?
We have a Java/JavaFX desktop application that has been running successfully on a Windows platform (Server 2012) for almost a year.
Recently we moved the application to a different Windows platform (Server 2019, virtual machine).
The app is installed on a shared drive and is started several times a day. It initially runs successfully but at some point in the day will no longer start.
The command line is:
java -p WolfToolkit.jar;WolfToolkit_mods -m com.mycompany.wolftoolkit/com.mycompany.start.StartGUI
WolfToolkit_mods is a folder containing jars for the required modules. When the start-up error occurs, Java.exe reports thatvarying required modules cannot be found. After a lot of diagnostic testing, it appears that Java.exe can no longer detect any of the jar files in the WolfToolkit_mods folder even though Windows Explorer shows the correct content.
If I copy folder WolfToolkit_mods to WolfToolkit_mods2 and change the command to
java -p WolfToolkit.jar;WolfToolkit_mods2...
then the app starts correctly.
If I re-copy just one of the jar files into WolfToolkit_mods and use the original command, then only that file is visible. If all files are re-copied then the app runs correctly.
So, the behaviour is as if Java suddenly views WolfToolkit_mods as being empty and only detects each jar file when it is copied back in. Meanwhile Windows sees no problems. I should also mention that on rare occasions Java.exe suddenly starts reporting that WolfToolkit.jar is "Module format not recognized". Again, re-copying the file resolves the issue.
Any ideas on what this could be or how to diagnose? Thanks.
Windows Server 2019 Standard v10.0
JVM: OpenJDK 64-bit Server v11.0.10+9
This looks to have been caused by the virus checker which was quarantining all .jar files as "suspicious". Presumably when java.exe was trying to read the files on the module path the virus checking software intervened and the effect was that java.exe couldn't locate module-info and so reported missing modules.
Thanks to those who took the time to respond.
I am trying to create symlink in java between two files in a network drive. (I have full access to the drives). I am running this java program in my local machine (Windows) and the filesystem is on Linux.
When I run the following code,
Files.createSymbolicLink(new File(destinationPath + fileName).toPath(), new File(thumbNailsSourcePath + fileName).toPath());
I get the following excepton on the destination folder
java.nio.file.FileSystemException: The file or directory is not a reparse point.
But, if I deploy the same java program to the same Linux server, then it creates symlinks successfully.
Please let me know if I can solve this issue. I would ideally like to have integration tests running without any problem in my local machine.
By running the same command from the Eclipse and from the command line I get 2 different results:
With Eclipse everything works fine, however with the command line I get the following error message:
PosixThing.java:17: error: error while writing PosixThing: PosixThing.class (Permission denied)
This error message does not appear if I run "sudo javac PosixThing.java".
As it if was not strange enough, the same code with a different file located in the same directory (Desktop) does not give me any problem. (I am talking about mere txt files just to test the PosixFilePermissions function).
I checked the file permissions and everything is -rw -rw -rw As well as the others'. Do not know why it happens only with that specific file.
Running on Ubuntu 11.10 jdk 1.7.
Any suggestion to what it might be?
It sounds like a file / filesystem permissions problem of some kind:
Check the owner, group and permissions for the file, and all directories on the file pathname.
Check that you are running Eclipse and your command shell as the same effective user.
Check that you are not attempting to write to some kind of "funky" file system; e.g. a Windows file system mounted on Linux, or a FUSE file system of some kind.
If you've got SELinux enabled, check that's not causing the problem. (That's unlikely.)
It is also possible that you are running different releases / versions of Java in the two contexts, or even that Eclipse's file system cache is out of sync. (It is not clear to me what contexts the code is actually running in.)
i need to execute a batch file as windows service.
For that i had created a batch file.
In this batch file i just add the below code to run a jar file.
java -jar myTest.jar
When i double click on the batch file..no problem .its working fine. It executes the jar file (a java application).
But the same batch file when i used in a windows service on a windows server, its not working.? Its just getting blinked to show the command window and gets closed. None of my code portion inside the jar file gets executed.
Another thing is i had successfully checked this from another windows server. Its working fine there.
Why this strange issue..??Can anyone help me out to solve the issue..
The service is not executed in the same environment as when you run the batch from an interactive Windows session. Make shure in the .bat file that change into the correct (working) directory, even with absolut path (cd \users\my\java\service), and maybe specify the full path to the java.exe. The other server do you mention could have a totally diferent setup of the environment, installed software, etc.
C:
cd \users\my\java\service
"\program files\java\jre\bin\java" -jar test.jar
Synopsis: When calling an executable that links to shared libraries from Java code on Tomcat, I get errors on Windows 2003 whereas the executable works great on a command prompt.
I wanted to do this in Linux, but, alas, got outvoted and have to implement it using Windows Server 2003. Here it goes,
I have a simple Java code running on Tomcat which, when it receives a "start" signal from another server has to run an external executable (written in C++, using shared library DLLs from OpenCV and ffmpeg) like so
String cmd = "c:\\workspace\\process_video.exe -video " + filename;
// Execute the command
Process proc = null;
try {
proc = rt.exec(cmd);
} catch (Exception e) {
System.out.println("VA-> Exception thrown in running the command!");
errorOut.append(e.getStackTrace().toString());
}
Now, when I run the command in process_video from a DOS command prompt, it works (doesn't matter which directory it's issued from). However, when it is run through the Tomcat->my Java code->rt.exec() chain, cmd doesn't get executed, although the exception doesn't get thrown. When I examine Windows event logs, I see an APPCHRASH event for process_video with Fault Module Name cv110.dll, which is one of the OpenCV DLLs I link from cmd.
One solution would be to stuff all the DLLs used in process_video into the tomcat\lib directory, but this hurts my programmatic sensibilities, so I want to know if there is a better way to solve this issue. What user does Tomcat use when running executables on Windows? Maybe I can give more privileges to that user? Should I add the DLL paths to Tomcat's configuration file?
Any help will be much appreciated,
Thanks!
Cuneyt
Add an entry in the PATH evironment variable that points to where your DLLs are. If this doesn't work for your app, you can try adding the entry to Tomcat's PATH. You have to modify the PATH variable of the process that will be loading the executable. Since your Java code probably shares a JVM (and hence a process) with the Tomcat executable, that will dictate which environment the PATH variable will need to be updated.
This is a Windows problem, not a Tomcat problem.
By default, Windows looks in %Path% for DLLs, which may not include the directory of the EXE file.
You can fix this by creating an empty file called process_video.exe.local in the same direcotry as the EXE ( i.e. c:\workspace )
You can also create a .manifest file, but this is a bit more complicated.