There seems to be a problem with Tomcat running external programs. I'm trying to use the keytool that is distributed with JDK 1.2.2 through a Servlet running on Tomcat.
 
The Bean code snippet is as follows:
 
------------------------------------------------------------------------------------------------------------------------------------------
 
 . . . . .
 
StringBuffer command = new StringBuffer();
 . . . . . .
  
//get a Runtime to interface with the environment in which the application is running
Runtime rt = Runtime.getRuntime();  
 
  try {
  
   //execute the keytool command and get the returned Process
   p = rt.exec(command.toString());
   
  } catch(IOException ioe) {
  
   throw new DigitalSignatureException(ioe.getMessage()); 
   
  } catch (SecurityException se) {
  
   throw new DigitalSignatureException(se.getMessage()); 
  }
  
  try {
   
   //tell the database that the user now has keypairs for a digital signature.
   DBEFDigitalSignature.newDigitalSignature(db, keyAlias, userID);  
   
  } catch(SQLException sqle) {
  
    throw new DigitalSignatureException(sqle.getMessage());
  }  
 
-------------------------------------------------------------------------------------------------------------------------------
 
As you can see, I get a Runtime instance and try to execute a command.
A new keystore is supposed to be created if one does not exists. However, no keystore is created and no exception is thrown. But the exit value of the Process is not 0, indicating that the process did not execute correctly. However, the command works fine from the command line. This leads me to believe that Tomcat has a problem running external programs. Is this the case?
 
Leon Bailey
Software Engineer

Reply via email to