I'm trying to launch an application from within an axis web service, but I can't understand what am I doing wrong. The class I used to generate the webservice is this:
public class Esecutore {
public String esegui(){
try {
ProcessBuilder builder=new ProcessBuilder("parser.bat");
builder.redirectErrorStream(true);
Process pr;
pr = builder.start();
InputStream stdout=pr.getInputStream();
OutputStream stdin=pr.getOutputStream();
BufferedReader br=new BufferedReader(new InputStreamReader(stdout));
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(stdin));
String line = br.readLine();
while(line!=null){
line=br.readLine();
}
int termine=pr.waitFor();
if(termine!=0){
return "errore nell'inserimento";
}
return "finito";
} catch (IOException e) {
// TODO Auto-generated catch block
return "errore: "+e.getMessage();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
return "errore: "+e.getMessage();
}
}
}
the batch file works correctly when I execute it from the command line, and it just launches a .jar, which doesn't need any input. However, I can see that when I do it through this code it has an exit state different from 0, and since the .jar should write to a database I also know from the db logs it doesn't get executed at all.