Note that there are some explanatory texts on larger screens.

plurals
  1. PORuntime.exec() won't finish properly
    primarykey
    data
    text
    <p>I've created a WebApp that relies on external scripts to gather query request by the user (internal software). I've tested, with sucess, the WebApp off the glassfish server provided by netbeans but whenever I try and upload my App to a third party server (Apache Tomcat) I run into the issue of the process.getRuntime exitValue never being written and the WebApp never gets to the result page....</p> <p>This is the code that I have implemented so far: </p> <p><strong>Update --> The code now works after reading both stderr and stdin:</strong></p> <pre><code> pd = new ProcessBuilder("runscript.bat"); pd.redirectErrorStream(true); process = pd.start(); StreamGobbler inputGobbler = new StreamGobbler(process.getInputStream(), "Input"); StreamGobbler errorGobbler = new StreamGobbler(process.getErrorStream(),"Error"); errorGobbler.start(); inputGobbler.start(); int exitVal = -1; try { exitVal = process.waitFor(); } catch (InterruptedException ex) { //log Error } class StreamGobbler extends Thread { OutputWriterReader outWR = new OutputWriterReader(); BufferedWriter deadWriter; InputStream is; // reads everything from is until empty. StreamGobbler(InputStream is, String type) { this.is = is; createWatch(type); } // depending on if Error stream or Input Stream private void createWatch(String type){ try { if(type.equals("Error")) deadWriter = new BufferedWriter(new FileWriter("StdError.txt")); else if(type.equals("Input")) deadWriter = new BufferedWriter(new FileWriter("StdInput.txt")); } catch (IOException ex) { //log Error } } @Override public void run() { try { InputStreamReader isr = new InputStreamReader(this.is); BufferedReader br = new BufferedReader(isr); String line=null; while ( (line = br.readLine()) != null) deadWriter.append(line); deadWriter.flush(); deadWriter.close(); } catch (IOException ioe) { //log Error } } </code></pre> <p>}</p> <p>Any Suggerstions? Thanks in advance for any help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload