This is not a repost, I am asking for the Amazon ec2 instance ! Questions that others asked worked fine on my local machine, and those were solved, but not on Amazon.
There have been several reports regarding this problem, but nothing solved this issue for me. To post a few solutions:
https://forum.openoffice.org/en/forum/viewtopic.php?p=88088
https://forum.openoffice.org/en/forum/viewtopic.php?f=16&t=4767&p=21890&hilit=jodconverter#p21890
https://forum.openoffice.org/en/forum/viewtopic.php?f=16&t=4767&p=21948&hilit=jodconverter#p21948
These are the steps I took:
- On a fresh EC2 Amazon instance, I have installed the libre office commons
$sudo apt-get install libreoffice-common
And then Maven
To run the service I am using (tried as sudo as well)
$soffice -nologo -nofirststartwizard -headless -norestore -invisible "-accept=socket,host=localhost,port=8100,tcpNoDelay=1;urp;"
All ports and all securities are open for the ec2 instance
This is my code
import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import java.io.File;
/**
* soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard
*/
public class testrun {
public static void main(String[] args){
try {
File inputFile = new File("./test.html");
File outputFile = new File("./OK.pdf");
// connect to an OpenOffice.org instance running on port 8100
SocketOpenOfficeConnection connection = new SocketOpenOfficeConnection("127.0.0.1", 8100);
connection.connect();
// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);
// close the connection
connection.disconnect();
}catch (Exception e){e.printStackTrace();}
}
}
- This is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>izbr</groupId>
<artifactId>izbr</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.artofsolving/jodconverter -->
<dependency>
<groupId>com.artofsolving</groupId>
<artifactId>jodconverter</artifactId>
<version>2.2.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.4.3</version>
</dependency>
</dependencies>
My Java version is openjdk version "1.8.0_91" OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-0ubuntu4~14.04-b14) OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
When I run
$mvn exec:java -Dexec.mainClass="testrun"
error is: 116 [testrun.main()] INFO com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection - connected com.artofsolving.jodconverter.openoffice.connection.OpenOfficeException: conversion failed: could not save output document at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.loadAndExport(OpenOfficeDocumentConverter.java:144) 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.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:74) at com.artofsolving.jodconverter.openoffice.converter.AbstractOpenOfficeDocumentConverter.convert(AbstractOpenOfficeDocumentConverter.java:70) at testrun.main(testrun.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:294) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.reflect.UndeclaredThrowableException at com.sun.proxy.$Proxy26.storeToURL(Unknown Source) at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.storeDocument(OpenOfficeDocumentConverter.java:156) at com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter.loadAndExport(OpenOfficeDocumentConverter.java:140) ... 11 more Caused by: com.sun.star.ucb.InteractiveAugmentedIOException: an error occurred during file opening at com.sun.star.lib.uno.environments.remote.Job.remoteUnoRequestRaisedException(Job.java:187) at com.sun.star.lib.uno.environments.remote.Job.execute(Job.java:153) at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:349) at com.sun.star.lib.uno.environments.remote.JobQueue.enter(JobQueue.java:318) at com.sun.star.lib.uno.environments.remote.JavaThreadPool.enter(JavaThreadPool.java:106) at com.sun.star.lib.uno.bridges.java_remote.java_remote_bridge.sendRequest(java_remote_bridge.java:657) at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.request(ProxyFactory.java:159) at com.sun.star.lib.uno.bridges.java_remote.ProxyFactory$Handler.invoke(ProxyFactory.java:141) ... 14 more
I have tried all suggestions such listing the listening ports and then changing the port number for soffice. Also running as sudo, and so on. No solution helped. I have done a chmod 777 on /usr/bin/soffice /usr/bin/X11/soffice but that did not work.
Please note that it is working on my mahcine, but not on Amazon ec2 even if all ports and services are open!