1

I am using follwing code to convert doc file to pdf using jodconvert library. it working fine some time only, some time it fire error as described below.

Code :

 try{
   Runtime rt = Runtime.getRuntime();  
   Process pSoffice = rt.exec(OpenOfficeConnString);
   File inputFile = srcDoc;
   String destDoc = srcDoc.getAbsolutePath().substring(0,
                    srcDoc.getAbsolutePath().lastIndexOf("."))
                    + "." + outputFileExt;

   outputFile = new File(destDoc);

   //connect to an OpenOffice.org instance running on port 8100
    OpenOfficeConnection connection = new SocketOpenOfficeConnection(
                    8100);
   connection.connect();
  // convert
   DocumentConverter converter = new OpenOfficeDocumentConverter(
                    connection);
   converter.convert(inputFile, outputFile);
// close the connection
   connection.disconnect();


}catch (Exception e) {
   e.printStackTrace();
}

Error :

java.net.ConnectException: connection failed: socket,host=localhost,port=8100,tcpNoDelay=1: java.net.ConnectException: Connection refused: connect
Butani Vijay
  • 4,181
  • 2
  • 29
  • 61
  • Well if you start a process via `Runtime.exec()` you don’t have control over the progress of the new process. In other word, maybe it is simply not ready yet. So waiting a bit before trying again would help. – Holger Sep 06 '13 at 08:06
  • Thanks @Holger do you know how can i resolved when multiple request try to use this service or process?. any other way to start process so i can control it. – Butani Vijay Sep 07 '13 at 04:05
  • No. But if that’s the problem in your case you should adapt your question to narrow the scope. Maybe others can help then. – Holger Sep 09 '13 at 09:38
  • Have you found any solution ? If yes, please do share. – Ranjan Jul 05 '18 at 10:51

0 Answers0