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!
EDIT: This worked for me, adjust the steps to your code. Changing the permission to folders and other answers I found were simply not helpful at all. I figured this out myself.
Upgrade/Update the instance
$ sudo apt-get upgrade
$ sudo apt-get update
Install java jdk 8
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
$ sudo apt-get install oracle-java8-set-default
Install Maven
$ sudo add-apt-repository "deb http://ppa.launchpad.net/natecarlson/maven3/ubuntu precise main"
$ sudo apt-get update
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6DTHIS_IS_HEX_FROM_ERRORFA0101
$ sudo apt-get install maven3
$ sudo ln -s /usr/share/maven3/bin/mvn /usr/bin/mvn
$ sudo apt-get update
Install LibreOffice (full!), and then check if there is a common, ususally there is
$ sudo apt-get install libreoffice
$ sudo apt-get install libreoffice-common
Open a new tab just for testing the connection, ssh to EC2 and do
$ soffice -nologo -nofirststartwizard -headless -norestore -invisible "-accept=socket,host=localhost,port=8100,tcpNoDelay=1;urp;"
Go to a project/testing and adjust the pom.xml
$ nano pom.xml
<dependency>
<groupId>com.artofsolving</groupId>
<artifactId>jodconverter</artifactId>
<version>2.2.1</version>
</dependency>
Adjust the source code so that the line A is changed with the line B, making sure that in-file and out-file (if any) are the right paths, and that they exist
A: OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
B: SocketOpenOfficeConnection connection = new SocketOpenOfficeConnection("127.0.0.1", 8100);
clean install the project with maven
$ mvn clean install
Run the project/test for example:
$ mvn exec:java -Dexec.mainClass="testrun"
Related
I have a small Spring Boot rest service that runs fine with:
java -jar myapp.jar
...but when I deploy in a docker container, it crashes the container when I access the service with curl:
A fatal error has been detected by the Java Runtime Environment:
SIGSEGV (0xb) at pc=0x00007f052205991a, pid=1, tid=40
JRE version: OpenJDK Runtime Environment Temurin-19.0.1+10 (19.0.1+10)
(build 19.0.1+10) Java VM: OpenJDK 64-Bit Server VM Temurin-19.0.1+10
(19.0.1+10, mixed mode, sharing, tiered, compressed oops, compressed
class pt> Problematic frame: V [libjvm.so+0xe2f91a]
JVM_handle_linux_signal+0x13a
The Dockerfile:
FROM amd64/eclipse-temurin:19.0.1_10-jre-alpine
VOLUME /opt/galleries
RUN mkdir -p /opt/rest.galleries/logs/
ARG JAR_FILE
ADD ${JAR_FILE} /opt/rest.galleries/app.jar
EXPOSE 8000
ENTRYPOINT ["java","-jar","/opt/rest.galleries/app.jar"]
Creating the container from the image:
docker run -p 8000:8000 -v /opt/galleries:/opt/galleries --memory="1g" --memory-swap="2g" -t craigfoote/rest.galleries:latest &
I am using these libraries to read webp and jpg images.:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-imaging</artifactId>
<version>1.0-alpha3</version>
</dependency>
<dependency>
<groupId>org.sejda.imageio</groupId>
<artifactId>webp-imageio</artifactId>
<version>0.1.6</version>
</dependency>
I'm building to a image via:
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.13</version>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>${project.artifactId}</repository>
<tag>${project.version}</tag>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
</plugin>
The point at which it crashes is a call to:
ImageIO.read(file); // where file is a 238kB webp image
Since it works at cmd line, I assume the code operation itself is not the problem but it may be causing it, perhaps a memory issue? I tried modifying the docker run command to increase ram and swap but it didn't help:
docker run -p 8000:8000 -v /opt/galleries:/opt/galleries --memory="4g" --memory-swap="8g" -t craigfoote/rest.galleries:latest &
When the crash occurs, the console states that a hs_err_pid1.log file was written but I can't find it.
Any ideas anyone?
It appears that the base image, amd64/eclipse-temurin:19.0.1_10-jre-alpine, uses a different libc than org.sejda.imageio:webp-imageio. I changed to ubuntu base and installed openjdk-19 and everything works now. My Dockerfile:
FROM ubuntu:latest
RUN apt update && \
apt install -y openjdk-19-jdk ca-certificates-java && \
apt clean && \
update-ca-certificates -f
ENV JAVA_HOME /usr/lib/jvm/java-19-openjdk-amd64/
RUN export JAVA_HOME
VOLUME /opt/galleries
RUN mkdir -p /opt/rest.galleries/logs/
ARG JAR_FILE
ADD ${JAR_FILE} /opt/rest.galleries/app.jar
EXPOSE 8000
ENTRYPOINT ["java","-jar","/opt/rest.galleries/app.jar"]
I am trying to create a RabbitMQ image that installs the rabbitmq_auth_backend_http plugin, and also executes a java application (.jar) via a bash script file. However, when I run the container I get this output from RabbitMQ:
/usr/local/bin/docker-deploy.sh: 2: /usr/local/bin/docker-deploy.sh:
: not found
Starting rabbit-sidecar application
Enabling plugins on node rabbit#039e6bd1bbfd:
bbitmq_auth_backend_http
The following plugins have been configured:
rabbitmq_auth_backend_http
rabbitmq_management
rabbitmq_management_agent
rabbitmq_web_dispatch
Applying plugin configuration to rabbit#039e6bd1bbfd...
The following plugins have been enabled:
rabbitmq_auth_backend_http
set 4 plugins.
Offline change; changes will take effect at broker restart.
/usr/local/bin/docker-deploy.sh: 4: /usr/local/bin/docker-deploy.sh: rabbitmq-server
: not found
It's also not finding rabbitmq-server which is needed to restart rabbit for the plugin to work.
To note, the java application appears to be working as it should and is just logging what it normally logs when its spun up as its own container.
Dockerfile
FROM rabbitmq:3.8.2-management
COPY ./rabbitmq.conf /etc/rabbitmq/rabbitmq.conf
RUN apt -y update && apt -y install openjdk-8-jdk
RUN mkdir /sidecar
ADD ./target/demo-0.0.1-SNAPSHOT.jar /sidecar/demo-0.0.1-SNAPSHOT.jar
ADD ./docker-deploy.sh /usr/local/bin/docker-deploy.sh
RUN chmod 755 /usr/local/bin/docker-deploy.sh #755
ENTRYPOINT ["sh", "/usr/local/bin/docker-deploy.sh"]
Script
#!/bin/bash
echo "Starting rabbit-sidecar application"
rabbitmq-plugins enable rabbitmq_auth_backend_http; rabbitmq-server
# starts the sidecar
java -jar /sidecar/demo-0.0.1-SNAPSHOT.jar
My original custom image that worked was this:
FROM rabbitmq:3.8.2-management
COPY rabbitmq.conf /etc/rabbitmq/rabbitmq.conf
CMD ["sh", "-c", "rabbitmq-plugins enable rabbitmq_auth_backend_http; rabbitmq-server"]
Which worked fine, but obviously I needed to do what I am doing because I want to be able to run another service within the same container as it requires it.
I did notice that there is a docker-entrypoint.sh in /usr/local/bin. Is this something to be considered in this context?
I installed tomcat7 but when I tried to start it. It fails to start.
previously I'd installed tomcat7 and it was working fine, But when I tried to add tomcat7 server in netbeans it gave me error of some Catalina home or something. I looked for that solution and applied. Then after adding the tomcat7 server to the netbeans, it won't start. Later I install glassfish server. It also got failed. So again I uninstalled the tomcat7 and tried again to start it. But now it is not getting started.
Creating config file /etc/logrotate.d/tomcat7 with new version
* Starting Tomcat servlet engine tomcat7 [fail]
invoke-rc.d: initscript tomcat7, action "start" failed.
Setting up tomcat7-admin (7.0.52-1ubuntu0.3) ...
Setting up tomcat7-docs (7.0.52-1ubuntu0.3) ...
Setting up tomcat7-examples (7.0.52-1ubuntu0.3) ...
Processing triggers for ureadahead (0.100.0-16) ...
Try this!
Step 1:
When Install tomcat 7 on Ubuntu 14.04
$ sudo apt-get install tomcat7
Step 2
If You find an error post installation which could look something similar to the code below:
Creating config file /etc/logrotate.d/tomcat7 with new version
* no JDK or JRE found - please set JAVA_HOME
invoke-rc.d: initscript tomcat7, action "start" failed.
Setting up authbind (2.1.1) ...
Processing triggers for ureadahead (0.100.0-16) ...
To rectify the above please do the following:
$ sudo mkdir -p /home/data/backup_scripts
$ cp /etc/init.d/tomcat7 /home/data/backup_scripts/
$ sudo vim /etc/init.d/tomcat7
After you open the file i.e tomcat7, please find the following line
JDK_DIRS="/usr/lib/jvm/default-java ${OPENJDKS} /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-sun /usr/lib/jvm/java-7-oracle"
Change the above line by appending the following to it:
/usr/lib/jvm/java-8-oracle
Thus the line would now become:
JDK_DIRS="/usr/lib/jvm/default-java ${OPENJDKS} /usr/lib/jvm/java-6-openjdk /usr/lib/jvm/java-6-sun /usr/lib/jvm/java-7-oracle /usr/lib/jvm/java-8-oracle"
Save the file and start the tomcat server. This time it should happen at ease:
$ sudo service tomcat7 start
Hope it works!!!
I'm trying to deploy a Vaadin 7 example.war file in tomcat 7, using an EC2 server. I upload the file to /var/lib/tomcat7/webapps but then when I go to myIp:8080/example it doesn't find the resource.
Any idea why?
Thanks!
You have to use the tomcat manager (usually http://[YourHost]:8080/manager) to add a new webapp / war file, it is not just uploading the file to the webapps folder.
To install tomcat, the manager webapp, and configuring access credentials (debian or debian based distros), check this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-apache-tomcat-on-a-debian-server
Solved!...
To install the manager:
sudo yum install tomcat7-webapps tomcat7-docs-webapp tomcat7-admin-webapps
To solve the Java Version mismatch, org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/prueba2]]:
On Eclipse:
Preferences >> Java >> Installed JREs
On EC2 server:
sudo yum remove java-1.7.0-openjdk
sudo yum install java-1.8.0
Then reinstall Tomcat7 and restart
Thanks #BlunT for all the help!!
I'm working on a bash script for automatic MongoDB server installation and user creation.
#!/bin/bash
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/mongodb.list
apt-get update
apt-get install -y mongodb-org
update-rc.d mongod defaults
sed -i 's/^auth = true/#auth = true/g' /etc/mongod.conf
sed -i 's/^#noauth = true/noauth = true/g' /etc/mongod.conf
service mongod restart
mongo user_creation.js
The script is run on a clean precise64 Vagrant VM. Add the Debian/Ubuntu repo to install the latest version (we're on Ubuntu 12.04 LTS, the maintained version is 2.0.X), add server to startup, set some variables in the MongoDB config file. Simple stuff really, however, the last line fails each and every time.
MongoDB shell version: 2.6.4 connecting to: test 2014-10-03T12:34.:56.000+0000
warning: Failed to connect to 127.0.0.1:27017, reason: errno:111 Connection refused
2014-10-03T12:34.:56.000+0000 Error: couldn't connect to server 127.0.0.1:27017
(127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146
exception: connect failed
I thought maybe the server needed some time to load data or some other kind of initialization between its restart and the client connection so I tried putting a sleep 30 between the last two instructions : didn't work. However, removing the mongo execution from the script and starting it manually works like a charm every time! The .js is not the problem here, I've tested it and it's working alright.
Does anyone have any idea why the mongo cannot connect on its first try and how I could fix this? For now, I'll settle with this terrible (working) hack, but I'd rather have a cleaner, hackless script:
while :
do
RESULT=`mongo --eval "1;"`
echo $RESULT
if [[ "${RESULT:-null}" == *Failed\ to\ connect* ]]
then
sleep 1
else
mongo root_creation.js
break;
fi
done
It's ugly but after 1 to 10 tries, it ends up connecting and working perfectly.