472,122 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,122 software developers and data experts.

JAVA IO Exception Create Process

Am writing a code for database backup....by backupservlet is as given below

i get the following exception

[#|2007-10-31T16:05:25.741+0530|INFO|sun-appserver-pe8.2|employeetransaction.DBBackupServlet|_ThreadI D=22;| About to execute the command exp hrms/manager file=C:\ET\ET\EmployeeTransaction\build\web\backup Dir\Weekly.dmp log=C:\ET\ET\EmployeeTransaction\build\web\logDir\ Weekly.log|#]
[#|2007-10-31T16:05:25.803+0530|WARNING|sun-appserver-pe8.2|javax.enterprise.system.stream.err|_ThreadID =22;|
java.io.IOException: CreateProcess: exp hrms/manager file=C:\ET\ET\EmployeeTransaction\build\web\backup Dir\Weekly.dmp log=C:\ET\ET\EmployeeTransaction\build\web\logDir\ Weekly.log error=2
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(ProcessImpl.java:81)
at java.lang.ProcessImpl.start(ProcessImpl.java:30)
at java.lang.ProcessBuilder.start(ProcessBuilder.java :451)
at java.lang.Runtime.exec(Runtime.java:591)
at java.lang.Runtime.exec(Runtime.java:429)
at java.lang.Runtime.exec(Runtime.java:326)
at employeetransaction.DBBackupServlet.processRequest (DBBackupServlet.java:183)
at employeetransaction.DBBackupServlet.doGet(DBBackup Servlet.java:307)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:747)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:860)
at sun.reflect.GeneratedMethodAccessor2305.invoke(Unk nown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.apache.catalina.security.SecurityUtil$1.run(Se curityUtil.java:249)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAsPrivileged(Subject .java:517)
at org.apache.catalina.security.SecurityUtil.execute( SecurityUtil.java:282)
at org.apache.catalina.security.SecurityUtil.doAsPriv ilege(SecurityUtil.java:165)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:257)
at org.apache.catalina.core.ApplicationFilterChain.ac cess$000(ApplicationFilterChain.java:55)
at org.apache.catalina.core.ApplicationFilterChain$1. run(ApplicationFilterChain.java:161)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:263)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:551)
at org.apache.catalina.core.StandardContextValve.invo keInternal(StandardContextValve.java:225)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:173)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:551)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:170)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:551)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:132)
at org.apache.catalina.core.StandardPipeline.invoke(S tandardPipeline.java:551)
at org.apache.catalina.core.ContainerBase.invoke(Cont ainerBase.java:933)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(Co yoteAdapter.java:189)
at com.sun.enterprise.web.connector.grizzly.Processor Task.doProcess(ProcessorTask.java:604)
at com.sun.enterprise.web.connector.grizzly.Processor Task.process(ProcessorTask.java:475)
at com.sun.enterprise.web.connector.grizzly.ReadTask. executeProcessorTask(ReadTask.java:371)
at com.sun.enterprise.web.connector.grizzly.ReadTask. doTask(ReadTask.java:264)
at com.sun.enterprise.web.connector.grizzly.TaskBase. run(TaskBase.java:281)
at com.sun.enterprise.web.connector.grizzly.WorkerThr ead.run(WorkerThread.java:83)
|#]
[#|2007-10-31T16:05:25.803+0530|SEVERE|sun-appserver-pe8.2|employeetransaction.DBBackupServlet|_ThreadI D=22;|state is null : false ::: state.isBusy() : false Exception in closing database connections.|#]



Expand|Select|Wrap|Line Numbers
  1.  
  2.  Runtime s=Runtime.getRuntime();
  3.  
  4.     //Process o=null;
  5.         String command = "exp "+usr+"/"+pwd+" file="+backupRealPath+backupFileName+" log="+logRealPath+logFileName;
  6.  
  7.         java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.INFO," About to execute the command " + command);
  8.         try
  9.         {
  10.            Process o=s.exec(command);
  11.              java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.INFO,o.toString()+ " Process has started " );
  12.             // any error message?
  13.             StreamGobbler errorGobbler = new StreamGobbler(o.getErrorStream(), "ERROR");            
  14.             // any output?
  15.             StreamGobbler outputGobbler = new StreamGobbler(o.getInputStream(), "OUTPUT" );
  16.  
  17.             // kick them off
  18.             errorGobbler.start();
  19.             outputGobbler.start();
  20.  
  21.             // any error???
  22.             int exitVal = o.waitFor();
  23.             java.util.logging.Logger.getLogger(getClass().getName()).log(java.util.logging.Level.INFO," Exit Value = " + exitVal);
  24.             errBuff = errorGobbler.getOutPut();
  25.             outBuff = outputGobbler.getOutPut();
  26.             servletOutputStream.println("The command "+command+" has been submitted.<br>");
  27.             servletOutputStream.println(errBuff.toString());
  28.             servletOutputStream.println(outBuff.toString());
  29.             if (exitVal == 0)
  30.                 servletOutputStream.println("The backup completed successfully.<br>");
  31.             else
  32.                 servletOutputStream.println("The backup terminated with error code "+exitVal+".<br>");
  33.         //   fos.flush();
  34.        //    fos.close();
  35.  
  36.         } catch (Throwable t)
  37.           {
  38.             t.printStackTrace();
  39.           }                        
  40.  
  41.           servletOutputStream.flush();
  42.           servletOutputStream.close();
  43.  
  44.  
My streamgobbler is
Expand|Select|Wrap|Line Numbers
  1.  
  2. /*
  3.  * StreamGobbler.java
  4.  *
  5.  * Created on October 9, 2007, 9:53 PM
  6.  *
  7.  * To change this template, choose Tools | Template Manager
  8.  * and open the template in the editor.
  9.  */
  10.  
  11. package employeetransaction;
  12.  
  13. /**
  14.  *
  15.  * @author kvishwas
  16.  */
  17. import java.util.*;
  18. import java.io.*;
  19. import javax.servlet.ServletOutputStream;
  20. import org.apache.naming.java.javaURLContextFactory;
  21.  
  22. /**
  23.  *
  24.  * @author kvishwas
  25.  */
  26. public class StreamGobbler extends Thread {
  27.  
  28.     /** Creates a new instance of StreamGobbler */
  29.     InputStream is;
  30.     String type;
  31.     StringBuffer out;
  32.     OutputStream os;
  33.  
  34.     public StreamGobbler(InputStream is, String type)
  35.     {
  36.         this.is = is;
  37.         this.type = type;
  38.         this.out = new StringBuffer();
  39.  
  40.  
  41.         }
  42.  
  43.  
  44.     /* 
  45.     public StreamGobbler(InputStream is, String type,OutputStream redirect)
  46.     {
  47.         this.is = is;
  48.         this.type = type;
  49.         this.os = redirect;
  50.     }
  51.     */
  52.  
  53.     public void run()
  54.     {
  55.         try
  56.         {
  57.             PrintWriter pw =null;
  58.             if(os!=null)
  59.                 pw=new PrintWriter(os);
  60.  
  61.             InputStreamReader isr = new InputStreamReader(is);
  62.             BufferedReader br = new BufferedReader(isr);
  63.             String line=null;
  64.             while ( (line = br.readLine()) != null)
  65.             {    
  66.                /* if(pw != null)
  67.                     pw.println(line);*/
  68.                 System.out.println(type + ">" + line);
  69.                String line1 = line + "<br>";
  70.                 out.append(line1);
  71.             }    
  72.               /*  if(pw != null)
  73.                     pw.flush();*/
  74.          } catch (IOException ioe)
  75.          {
  76.             ioe.printStackTrace();  
  77.          }
  78.     }
  79.  
  80.     public StringBuffer getOutPut()
  81.     {
  82.         return out;
  83.     }
  84.  
  85.  
  86. }
  87.  
  88.  
Oct 31 '07 #1
1 4289
r035198x
13,262 8TB
What happens when you run the command

Expand|Select|Wrap|Line Numbers
  1. exp hrms/manager file=C:\ET\ET\EmployeeTransaction\build\web\backupDir\Weekly.dmp log=C:\ET\ET\EmployeeTransaction\build\web\logDir\Weekly.log
  2.  
manually on the console?
Nov 1 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by ptaz | last post: by
4 posts views Thread by Peter | last post: by
1 post views Thread by audiokarate | last post: by
3 posts views Thread by mdshafi01 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.