EXE crash when calling from ProcessBuilder in java

I call some EXE (7za.exe, pg_basebackup.exe, ...) from JAVA ProcessBuilder. It works without any problems for 2 or 3 days (EXE will be called daily). After that, the EXE constantly crashes.

7za.exe error:
Exit Code :: -1.073.741.502

Windows event log error:
Invalid application name: 7za.exe, version: 9.20.0.0, timestamp: 0x4ce553f5 Invalid module name: KERNELBASE.dll, version: 6.2.9200.21941, time stamp: 0x5792e533
Exception Code: 0xc0000142
Error Offset: 0x000683ba
Failure Process ID: 0x10bc
Application Launch Failure: 0x01d2cebdff3bb05a
Application path error: EXEpath \ bin \ 7za.exe
Crash module path: KERNELBASE.dll
Report ID: 3d27046a-3ab1-11e7-93fe-00505680156e
Failure of the full package name:
Error accessing batch application id:

Code snippet

File workingDir = new File(workingDirectory); ProcessBuilder pb = new ProcessBuilder(argumentsList); pb.redirectErrorStream(true); pb.directory(workingDir); Process process = pb.start(); BufferedReader commandOutput = new BufferedReader(new InputStreamReader(process.getInputStream())); String s = null; while ((s = commandOutput.readLine()) != null) { print(s); } int exitCode = process.exitValue(); 

Also, this does not happen on all machines that run this code. Is it a memory error or an OS level error? Please inform.

Thanks in advance.

Edit 1: Same error in C #. It also contains a fix.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/cb9a15ed-4401-47f1-8c78-0c63c3da677d/process-returns-0xc0000142-when-started-from-a-windows-service-prividing- the-credentials? forum = clr
How to achieve this in java?

Edit 2: Java works as a service (using wrapper )
Java Version: 1.0.051
Windows version: Windows Server 2012 and R2 (64 bit), Windows 7 (64 bit), Windows 8 (64 bit)

+7
java exe windows processbuilder
source share
1 answer

Thus, I agree with the above comments, asking for additional information to determine the root cause of this problem (number of processes when problems occur, instance indicators, etc.). Generally speaking, I would say that it is an anti-template for calling an executable from java, if you can avoid it. In this case, I would recommend you try replacing the call with the executable with something like 7-zip binding .

This should help you better understand how the basic processes are performed, and will move ownership and process control in the JVM.

0
source share

All Articles