P
pwaring
I've got a fairly complex existing Tomcat application (which is
packaged and built as a .war file) which I'm trying to edit so that it
calls a Perl script part way through the processing, which will
generate an XML file used later on. I think I've worked out how to
call external scripts from within Java, but at the moment when I try
and access the application via Tomcat the application either hangs or
bails out (I don't know which, as the log files unhelpfully don't give
any error messages).
The code which is causing the problem looks like this:
System.err.println("Calling runtime...");
Runtime runtime = Runtime.getRuntime();
System.err.println("Executing process...");
Process process = runtime.exec("/path/to/ysearch.pl 'News' '\"search
query\"' 'file");
System.err.println("Waiting for process...");
int exitVal = process.waitFor();
System.out.println("Exited with error code: " + exitVal);
The code gets as far as "Executing process..", beyond that there is
nothing in the log file so I presume the runtime.exec() call is where
the problem is. I'm not interested in reading the output from the
script (there shouldn't be any), so that's not an issue, and the
permissions on it allow anyone to read or execute ysearch.pl so I
don't think there's a problem in that area.
Does anyone have any suggestions which I could try to get this to
work? I've only been using Tomcat for a week (I'm picking up on
someone else's code) so I might have made a beginner's mistake. I'm
using Tomcat 5 on Fedora Core 7, and Java 1.5.0_01 (I can't easily
change any of those).
packaged and built as a .war file) which I'm trying to edit so that it
calls a Perl script part way through the processing, which will
generate an XML file used later on. I think I've worked out how to
call external scripts from within Java, but at the moment when I try
and access the application via Tomcat the application either hangs or
bails out (I don't know which, as the log files unhelpfully don't give
any error messages).
The code which is causing the problem looks like this:
System.err.println("Calling runtime...");
Runtime runtime = Runtime.getRuntime();
System.err.println("Executing process...");
Process process = runtime.exec("/path/to/ysearch.pl 'News' '\"search
query\"' 'file");
System.err.println("Waiting for process...");
int exitVal = process.waitFor();
System.out.println("Exited with error code: " + exitVal);
The code gets as far as "Executing process..", beyond that there is
nothing in the log file so I presume the runtime.exec() call is where
the problem is. I'm not interested in reading the output from the
script (there shouldn't be any), so that's not an issue, and the
permissions on it allow anyone to read or execute ysearch.pl so I
don't think there's a problem in that area.
Does anyone have any suggestions which I could try to get this to
work? I've only been using Tomcat for a week (I'm picking up on
someone else's code) so I might have made a beginner's mistake. I'm
using Tomcat 5 on Fedora Core 7, and Java 1.5.0_01 (I can't easily
change any of those).