0

I'm trying to run the amazon-provided python AWS Example for transcribing an audio file in a Java program using "System.exec()". I've substituted the various parts of the program to use parameters passed in. This code works as expected on a Mac, but in Windows (under Tomcat Service), the exact same System.exec() always returns null.

Basic Python code is here: https://docs.aws.amazon.com/code-samples/latest/catalog/python-transcribe-getting_started.py.html

I thought it might be an authentication problem, but I've authenticated trying the config file in the expected location, Environment Variables, and even System.setProperty() statements. Still always null.

Here's the Java code:

    process = Runtime.getRuntime().exec(cmdArray);
    reader = new BufferedReader(new InputStreamReader(process.getInputStream()));

The command array has:

  1. python
  2. path to python 'py' file
  3. parameters

The code crashes on the subsequent line (null): reader.readLine()

I have the Tomcat service set up to use 8MB RAM and have re-installed Tomcat to the latest 9 release.

If I take the individual parameters at the command line and execute them, it's all fine.

Would appreciate any suggestions.

Thanks in advance.

Morkus
  • 517
  • 7
  • 21
  • 1
    Please add the entire code (especially the line that has a `NullPointerException`) and the stack trace of the error to your question. – Piotr P. Karwasz Sep 13 '21 at 16:24
  • I can do that, but I think the problem is elsewhere. If I run the WAR file from Tomcat Service, then I have the problem. But, if I run the exact same WAR file with a standalone Tomcat instance (not started by the Service), the code works! I think there's some kind of security thing going on with the service, but I don't know what it is. Any ideas? Thanks. – Morkus Sep 13 '21 at 17:28
  • I am passing the key and secret key right in the aws transcribe file and it works on both Windows and Mac with standalone Tomcat (with no needed credentials file in ~/.aws. The Tomcat Service on Windows however, does not work. Something going on there I don't understand. – Morkus Sep 13 '21 at 18:38

0 Answers0