timolee / jodconverter

Automatically exported from code.google.com/p/jodconverter
0 stars 0 forks source link

Failed to start and connect to soffice.exe on Windows #103

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. This code will fail with OfficeException: failed to start and connect at 
Windows platforms:

DefaultOfficeManagerConfiguration config =  new 
DefaultOfficeManagerConfiguration();
config.setOfficeHome("C:\\Program Files\\LibreOffice 3.5");
OfficeManager officeManager = config.buildOfficeManager();
officeManager.start();

Stack trace:

org.artofsolving.jodconverter.office.OfficeProcess start
INFO: started process
Exception in thread "main" 
org.artofsolving.jodconverter.office.OfficeException: failed to start and 
connect
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess.startAndWait(ManagedOfficeProcess.java:64)
    at org.artofsolving.jodconverter.office.PooledOfficeManager.start(PooledOfficeManager.java:101)
    at org.artofsolving.jodconverter.office.ProcessPoolOfficeManager.start(ProcessPoolOfficeManager.java:62)
    at Snippet.main(Snippet.java:13)
Caused by: java.util.concurrent.ExecutionException: 
org.artofsolving.jodconverter.office.OfficeException: could not establish 
connection
    at java.util.concurrent.FutureTask$Sync.innerGet(Unknown Source)
    at java.util.concurrent.FutureTask.get(Unknown Source)
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess.startAndWait(ManagedOfficeProcess.java:62)
    ... 3 more
Caused by: org.artofsolving.jodconverter.office.OfficeException: could not 
establish connection
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess.doStartProcessAndConnect(ManagedOfficeProcess.java:142)
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess.access$0(ManagedOfficeProcess.java:117)
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess$1.run(ManagedOfficeProcess.java:58)
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
    at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
    at java.util.concurrent.FutureTask.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: org.artofsolving.jodconverter.office.OfficeException: office process 
died with exit code -1073741515
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess$6.attempt(ManagedOfficeProcess.java:136)
    at org.artofsolving.jodconverter.office.Retryable.execute(Retryable.java:40)
    at org.artofsolving.jodconverter.office.Retryable.execute(Retryable.java:30)
    at org.artofsolving.jodconverter.office.ManagedOfficeProcess.doStartProcessAndConnect(ManagedOfficeProcess.java:140)
    ... 8 more

What is the expected output? What do you see instead?

Windows platform is not supported in method getOfficeExecutable() of class 
org.artofsolving.jodconverter.office.OfficeUtils:

public static File getOfficeExecutable(File officeHome)
{
   if (PlatformUtils.isMac()) {
      return new File(officeHome, "MacOS/soffice.bin");
   } else {
      return new File(officeHome, "program/soffice.bin");
   }
}

This method should return the soffice.exe if platform is Windows:

public static File getOfficeExecutable(File officeHome)
{
   if (PlatformUtils.isWindows()) {
      return new File(officeHome, "MacOS/soffice.bin");
   } else if (PlatformUtils.isWindows()) {
      return new File(officeHome, "program/soffice.exe");
   } else {
      return new File(officeHome, "program/soffice.bin");
   }
}

Original issue reported on code.google.com by andreas....@gmail.com on 25 Jan 2012 at 9:03

GoogleCodeExporter commented 9 years ago
I'm sorry, the correct implementation should look like this:

public static File getOfficeExecutable(File officeHome)
{
   if (PlatformUtils.isMac()) {
      return new File(officeHome, "MacOS/soffice.bin");
   } else if (PlatformUtils.isWindows()) {
      return new File(officeHome, "program/soffice.exe");
   } else {
      return new File(officeHome, "program/soffice.bin");
   }
}

Original comment by andreas....@gmail.com on 25 Jan 2012 at 9:06

GoogleCodeExporter commented 9 years ago
Hello Andreas,

the code in the OfficeUtils.getOfficeExecutable() for is correct.
For Windows it should return "program/soffice.bin" and not the .exe wrapper.

The issue with LibreOffice 3.5 on Windows has a different background.
There is a code in the 
org.artofsolving.jodconverter.office.OfficeProcess.addBasisAndUrePaths(ProcessBu
ilder) method which supposed to add path to the URE\bin folder of the office 
home to the PATH environment variable.

The problem is that the code checks for the presence of the "basis-link" file 
in the office home. This is the case for OpenOffice 3.3 and LibreOffice 3.4.

But in LibreOffice 3.5 there is no such file. So the PATH environment variable 
is not set correctly and I am getting an error connecting to the LibreOffice 
process (same as you).

The attached patch for the OfficeProcess class (against 3.0-beta-4 codebase) 
solved the problem for us.

Kind regards
Sergiy

Sergiy Shyrkov
Product Development
---------------------------------
Jahia Solutions Group
web: http://www.jahia.com
---------------------------------
Jahia's next-generation, open source CMS stems from a widely acknowledged 
vision of enterprise application convergence – web, search, document, social 
and portal – unified by the simplicity of web content management. 

Original comment by Sergiy.Shyrkov on 23 Feb 2012 at 11:56

Attachments:

GoogleCodeExporter commented 9 years ago
Hi guys, any plan to release new version ?

Original comment by mletyn...@gmail.com on 24 Apr 2012 at 11:40

GoogleCodeExporter commented 9 years ago
Excellent Idea !! I don't know how to build the sources... If any one could 
apply this patch and ad the build to the project it would be find !

Original comment by r...@formaltis.fr on 28 Jun 2012 at 1:55

GoogleCodeExporter commented 9 years ago
Hello,

if you are not building from source on your own, you could perhaps give a try 
to the patches version, we use:

https://devtools.jahia.com/nexus/content/groups/public/org/artofsolving/jodconve
rter/jodconverter-core/3.0-beta-4-jahia2/

Kind regards
Sergiy

Original comment by Sergiy.Shyrkov on 9 Jul 2012 at 5:02

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I too have this problem, that it fails on windows with 
Apache_OpenOffice_incubating_3.4.1_win_x86_install_en-US.exe

I also have LibreOffice_4.0.1 installed, and it ignores that anyway.

Original comment by racu...@gmail.com on 22 Mar 2013 at 1:13

GoogleCodeExporter commented 9 years ago
I had to apply [#1 andreas....@gmail.com] and [#2 Sergiy.Shyrkov] to get it to 
work

Original comment by houman.b...@gmail.com on 26 Jun 2013 at 10:49