Reputation: 73
I have a requirement where I need to use openoffice in a standalone server and use a Java program for Document conversion.
Right now, I have a setup where I have started openoffice in my linux environment by using below command
sudo -H /opt/openoffice4/program/soffice '-accept=socket,host=localhost,port=8080;urp;StarOffice.ServiceManager' -nologo -headless -nofirststartwizard
As per my understanding, the above code starts openoffice and it is listening in port 8080.
Now my code uses JODConverter to create a connection between my java program and openoffice and the perform conversion between formats like DOC to PDF and so on.
Initially, I tried placing the java program in my linux server where openoffice was running. It was working fine and conversion was happening.
The imports I am using are as follows
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.DocumentFormat;
The connection was happening through the below line.
OpenOfficeConnection openofficeConnection = new SocketOpenOfficeConnection(8080);
openofficeConnection.connect();
The conversion is done by using the following lines of code.
File inputFile = new File("SomeInputFilePath");
File outputFile = new File("SomeOutputFilePath");
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
DocumentFormat inFormat = getDocumentFormat().getFormatByFileExtension("SomeInputFormatExtension");
DocumentFormat outputFormat = getDocumentFormat().getFormatByFileExtension("SomeOutputFormatExtension");
converter.convert(inputFile, inFormat, outputFile, outputFormat);
Now I am trying to achieve the same, by placing the code in my local system and running openoffice in the server. By this we try to remove the dependency of having openoffice installed in the machine where the code is running.
I have modified this line to establish connection and was able to establish a connection between my Java program running in my local and OpenOffice in the server.
OpenOfficeConnection openofficeConnection = new SocketOpenOfficeConnection("SomeServerIP",8080);
openofficeConnection.connect();
But I am getting the below exception inside the OpenOfficeDocumentConverter jar in the line
converter.convert(inputFile, inFormat, outputFile, outputFormat);
.
com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException: conversion failed: could not load input document
at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.loadAndExport(OpenOfficeDocumentConverter.java:131)
at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.convertInternal(OpenOfficeDocumentConverter.java:120)
at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:104)
at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.convertInternal(OpenOfficeDocumentConverter.java:88)
at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:82)
at wordHandle.WordHandleApi.main(WordHandleApi.java:44)
Caused by: com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported one.
at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:177)
at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:143)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:335)
at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:304)
at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:91)
at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:639)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:151)
at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:133)
at com.sun.proxy.$Proxy5.loadComponentFromURL(Unknown Source)
at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.loadDocument(OpenOfficeDocumentConverter.java:150)
at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.loadAndExport(OpenOfficeDocumentConverter.java:127)
... 5 more
What should be done to resolve this?
Is there any other way to achieve this?
Upvotes: 0
Views: 760