views:

215

answers:

1

In our project the Java webservice communicate with the backend program written in C and Perl to process. We are using the ProcessBuilderto execute a backend (UNIX) job FrameworkHandler.

ProcessBuilder process;
process.Start(FrameworkHandler -a ACTION)

FrameworkHandler invokes a Perl script to perform some action. The Perl script internally does a diff command between two XML files and uses the print function to print the error:

sub print_error
{
    $err_msg = shift;
    print STDERR "$err_msg\n";
}

Whenever there is a difference between the files the Perl program hangs in the print_error function. If we execute the Perl program in the UNIX shell it is working without any issues. But if we execute the Perl through the webservice, it is not returning after the diff command. Due to this, the webservice is also not returning the response. Whether the greater than (>) symbols in the XML tags are creating problem?

Any help is much appreciated.

Part of Error:


< diff -udr --new-file --label=postProcess1 --label=postProcess2 postProcess1 postProcess2
< --- postProcess1
< +++ postProcess2
< @@ -124,6 +124,36 @@
<               <LOCATION></LOCATION>
<               <ADDRESS_PART1>Test Address ^D</ADDRESS_PART1 >
<         </address_details>
< +       <address_details>
< +             <CITY></CITY>
< +             <STATE>12</STATE>


Thanks, Mathew Liju

+2  A: 

The API docs say:

“Because some native platforms only provide limited buffer size for standard input and output streams, failure to promptly write the input stream or read the output stream of the subprocess may cause the subprocess to block, and even deadlock.”

Are you complying?

Bombe
No we are not complying. We are planning to read the stdout in a thread and stderr in another thread. Any other suggestions to overcome this?
Liju Mathew