title: Apache commons command line execute method is returning exit code -1 when running in tomcat application and throwing ExecuteException
body: <p>Using Aapche commons CommandLine library, i am trying to execute an openssl command in a web application running in tomcat in SLES OS. below is the code snippet -</p>
  <pre><code>     CommandLine cmd = new CommandLine(&quot;/usr/bin/openssl&quot;)
                  .addArgument(&quot;genrsa&quot;)
                  .addArgument(&quot;-out&quot;)
                  .addArgument(&quot;/root/testcert_tomcat.key&quot;)
                  .addArgument(&quot;4096&quot;);
          logger.info(&quot;Command - &quot;+ cmd.toString());
  
          DefaultExecutor executor = new DefaultExecutor();
          executor.setProcessDestroyer(new ShutdownHookProcessDestroyer());
          executor.setStreamHandler(new PumpStreamHandler(null, null, null));
          executor.setWatchdog(new ExecuteWatchdog(60000));
          executor.setExitValue(0);
          try {
              int exitValue = executor.execute(cmd);
              if(exitValue != 0 ){
                 logger.info(&quot;Exit value  - &quot;+ exitValue);
              }
          } catch (IOException ex) {
              logger.info(&quot;Exception - &quot;+ ex.getMessage());
  
              return false;
          } 
  </code></pre>
  <p>command - openssl genrsa -out test.key 4096</p>
  <p>same command works fine when running from a normal java code outside tomcat web application or directly from shell command line. If someone has any idea please suggest what could be the issue.</p>
  <p>Exception caught - org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)</p>
  <p>Not so sure but i tried to check the tomcat user, it is running as root -</p>
  <pre><code>libv222:/usr/share/tomcat/webapps # ps auxwww | grep -v grep | grep tomcat
  
  tomcat   13700 27.7 12.3 3610620 498412 ?      Ssl  20:20   0:46 /usr/bin/java -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=5000,suspend=n -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/tmp -Djava.security.auth.login.config=/usr/share/tomcat/conf/jaas.config -Djava.library.path=/lib/emc/powerpath/remote_tools/latest/ -XX:MaxPermSize=128M -Xms512m -Xmx1536m -classpath /usr/share/tomcat/bin/bootstrap.jar:/usr/share/tomcat/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat -Dcatalina.home=/usr/share/tomcat -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat/temp -Djava.util.logging.config.file=/usr/share/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start
  
  root     16591  0.0  0.0   4244   728 pts/0    S+   17:34   0:00 tail -f /var/log/tomcat/catalina.out
  </code></pre>